During the Transformers movie, Optimus Prime was fatally wounded during a battle with the decepticons. On his deathbed he handed over the creation matrix, which gave the robots their life, to Ultra Magnus, who took over as leader. Sadly he wasn't much cop as a leader.
Later in the story, one of the younger autobots, Hotrod, took over as leader after a semi-religious experience during another battle on a junkyard planet turned him into "rodimus prime"
Or at least that's how I remember the story going. Anyone remember more?