Well, this is a wonderful question and it is one that had always interested me!
Consider the Interstellar Medium as a volume of space (very big!) full of…dust, radiation, particles and gas (mainly hydrogen). Ok the density is quite low but they are there. So focus on one of these Interstellar Clouds of dust and gas and think that it starts to contract (under the action of gravitational force). You can think of a particle…alone…it passes near (probably billions of kilometres and more) to another particle and attracts it…it is not a lot but they are now tangled and together they can “tangle” other more distant particles (that before were outside their reach) because they combined mass is now higher than before and have more gravitational influence around them.
After a long time our little core of few particles slowly rotating has attracted a lot of interstellar medium and the dust, particles and gas are now forming a dense ball that keeps on attracting stuff and getting denser and hotter, a Protostar .
Dust starts to collide in the confined space of the core producing heat (friction) emitted as infrared radiation. The heat is transported through the star medium up to the surface through the process of convection (as in a pan of boiling water where the movement communicates heat to various parts of the mass of water). The luminosity is quite high as the core keeps on accreting material for #10^5# years!
But then the outer layer of our contracting system starts to become denser as well and opaque to infrared radiation and, as a blanket, maintains the interior hot, slowing down the collapse (the time scale to reach this stage is of the order of 1 million years!).
The core still evolves accreting more material and heating up and heating (through radiation of heat now) the outer layers of our Pre-Main Sequence (PMS) star that becomes less opaque and start to shine.
Eventually the core heat up to a few million kelvins and thermonuclear reactions start. When the star gets most of its energy from thermonuclear reactions (rather than from gravitational contraction) the star is born! The structure is said to be in (hydrostatic) equilibrium and becomes a Zero-Age Main-Sequence star. The newborn star settles down in its life converting hydrogen into helium in its core and radiating energy. The total process takes approximately 20 million years.
The place that probably play an essential role in this process of star formation is called a Giant Molecular Cloud (GMC) such as the Star-Forming region near Orion:
In these GMC regions the molecular medium (mainly hydrogen) is bound into giant clouds that at the core are slightly denser than the surrounding medium and at temperatures of the order of 10 K. Young stars are always found near these “cloud” complexes suggesting that they work as “nurseries” for the birthing stars as in the case of H-II region of Eagle Nebula (M16-NGC6611) known as The Pillars of Creation:
Described beautifully as: “Eerie, dramatic new pictures from Hubble Space Telescope show newborn stars emerging from 'eggs' but rather dense, compact pockets of interstellar gas called evaporating gaseous globules (EGGs). Hubble found the EGGs, appropriately enough, in the Eagle nebula, a nearby star-forming region 6,500 light-years away in the constellation Serpens.”
[News Release STScI-1995-44]
(Pictures and data reference: M. Zeilik, S. A. Gregory, E. v. P. Smith, Introductory Astronomy and Astrophysics, Saunders College Publishing,1992).