Once collapse starts, instabilities cause the cloud to divide into successively smaller fragments of about the Jeans mass (see gravitational instability). At first, radiation can escape freely but eventually, when the cloud becomes dense enough, the opacity increases and the temperature rises, at which point fragmentation ceases. These final fragments are protostars, which now collapse individually. This collapse is gentle at first but after some hundred thousand years (for a star of one solar mass) the density and temperature rise sharply at the center, forming a hot core that will be the future nucleus of the star. Theoretical models show that the protostar will contract along the Hayashi track in the Hertzsprung–Russell diagram. The slow contraction heats the core to a temperature of 10 million kelvin, which is sufficient to initiate nuclear fusion reactions in hydrogen. Once the nuclear energy source is established, the contraction is halted and the star joins the main sequence.
Infrared and radio observations of star-formation regions are now filling out the theory. The infrared satellite IRAS found many small infrared sources within molecular clouds and Bok globules. Most are probably young stars still cocooned in dust, but a few may be true protostars. Molecular-line radio astronomy has revealed the gas motions in regions of star formation. Predicted infall velocities are very low and are often masked by random motions in the gas. Despite this, infall has now possibly been detected in a few cases. In addition, surprisingly high velocity gas has been revealed near the young stars at the center, forming two oppositely directed beams – bipolar outflows – from the massive young stars. These outflows must affect star formation in the cloud, either disrupting protostars or promoting their formation by compressing the surrounding gas. Young stars are often surrounded by disks of dense gas and dust. The disks are apparently more common among single stars than in multiple-star systems, and may be the precursors of planetary systems. The gas in the disk may be spiraling inward and increasing the star's mass substantially, after hydrogen fusion begins. The effects of bipolar outflows and late accretion from a surrounding disk have yet to be incorporated into theoretical models; they may alter quite substantially the simple theory given above.
Although stars in small molecular clouds and Bok globules are often single, most stars form in dense clusters. Such clusters also contain compact gas clumps that emit powerful maser radiation from water molecules (see maser source).
The young stars gradually dissipate the surrounding gas cloud by the effects of heating, radiation pressure, and the gas outflows. The latter often break through first, indicating the presence of the star by an optical bipolar nebula or a string of Herbig–Haro objects. When massive O and B stars are present, they light up the residual gas as an H II region. The massive stars take the shortest time to form, 100 000 years or less, and are normal main-sequence stars by the time they become visible. Less-massive stars are seen while they are still contracting and have appreciable amounts of surrounding gas and dust: these pre-main-sequence stars appear as Be, Ae, and T Tauri stars. A star like the Sun takes 50 million years to reach the main sequence.