The mass of a protostar is calculated from the infall and dispersal of an isothermal sphere in a uniform background. For high contrast between peak and background densities and for short dispersal time td, the accretion is ``self-limiting''; gas beyond the core is dispersed before it accretes, and the protostar mass approaches a time-independent value of low mass. For lower density contrast and longer dispersal time, the accretion ``runs away''; gas accretes from beyond the core, and the protostar mass approaches massive star values. The final protostar mass is approximately the initial gas mass whose free-fall time equals td. This mass matches the peak of the IMF for gas temperature 10 K, peak and background densities 106 and 103/cm3, respectively, and td comparable to the core free-fall time tcore. The accretion luminosity exceeds 1 L☉ for 0.1 Myr, as in the ``Class 0'' phase. For td/tcore=0.4-0.8 and temperature 7-50 K, self-limiting protostar masses are 0.08-5 M☉. These protostar and core masses have ratio 0.4±0.2, as expected if the core mass distribution and the initial mass function have the same shape.