The following is the plot and summary for Transformers 3, Dark of the Moon.
The Autobots on earth learn that the space race of the 1960s was actually because an alien spaceship was found on the moon. That alien spaceship crashed on the moon. Inside the spaceship was the remains of Sentinel Prime. Before the war between the Autobots and Decepticons, the Transformers were united, lead by Sentinel Prime. His second in commands were Optimus and Megatron. Megatron was in charge of the military, and Optimus was in charge of scientific research. Megatron problaimed himself king, and tried to kill Sentinel Prime. Optimus and some friends saved Sentinel, and they formed a group called the Autobots to oppose Megatron and the Decepticons. The only chance for an Autobots victory and saving of Cybertron was to leave Cybertron with a spaceship. That was the spaceship that later crashed on the moon. Inside that spaceship was Sentinel Prime along with pillars that could teleport Cybertron. The spaceship was shot down by Starscream, hence it crashed on the moon, killing Sentinel (who was piloting the spaceship).
Now fast forward to the present day. The Autobots learn about Sentinel Prime in the crashed spaceship on the moon. The Decepticons learn about this too. Optimus rescues Sentinel and brings him back to life with the Matrix of Leadership, Sentinel later kills Ironhide in one shot, and reveals that he made a secret alliance with the Decepticons. The Twins die trying to fight Sentinel, but are no match for Sentinel’s iron rust blaster. The iron rust blaster kills anything it hits.
Thousands of Decepticons come to earth, and the Autobots are vastly outnumbered. The Autobots race against time to save the earth. Countless Autobots die along the way. Shockwave is the Transformer who brings the Decepticons from Cybertron to earth. Eventually, Shockwave and Starscream are killed. Near the end, Sentinel gets into an argument with Megatron, and hurts Megatron badly. Optimus fights Sentinel, but is almost killed. Sentinel stole Megatron’s place as the leader of the Decepticons. Megatron becomes angry, and he helps Optimus defeat Sentinel.
Optimus has the chance to kill Megatron in one shot, but he doesn’t. Megatron says that he is tired of endless war. They make peace, and promise to work together in the future to go home and rebuild a war-ravaged Cybertron.