Gravity gathers a nebula
A star begins in a cloud of gas and dust called a nebula. Gravitational attraction pulls this material together. As the cloud contracts, gravitational potential energy is transferred and the material becomes hotter, forming a protostar. The central density and temperature rise. A protostar is not yet a stable main-sequence star: its core must become hot enough for sustained nuclear fusion.