As the cloud collapses , individual conglomerations of dense dust and gas form " Bok globules " . As a globule collapses and the density increases , the gravitational energy converts into heat and the temperature rises . When the protostellar cloud has approximately reached the stable condition of hydrostatic equilibrium , a protostar forms at the core . These pre – main sequence stars are often surrounded by a protoplanetary disk and powered mainly by the conversion of gravitational energy . The period of gravitational contraction lasts about 10 to 15 million years .