Stars are basically huge balls of hydrogen gas.
The hydrogen clouds collapse very slowly, although they can be speeded up by the effects of a passing star, or the shockwave from a distant supernova explosion. As the cloud collapses, it speeds up its rotation, and pulls more material into the centre, where a denser ball of gas, the 'protostar' forms. The protostar collapses under its own weight, and the collisions between hydrogen molecules inside it generate heat. Eventually the star becomes hot enough for the hydrogen molecules to split apart, and form atoms of hydrogen. Energy is released from the core, and pushes its way out through the rest of the star, creating an outward pressure which stops the star's collapse.