In 17,000 B.C., the Seven Primes traveled the galaxy to create Energon with star-absorbing machines called Sun Harvesters. The Primes followed a rule in which to never destroy planets with life, but one of them, Megatronus Prime, later known as The Fallen, defies the rule and sets up a Sun Harvester on Earth, a planet with abundant life. After defeating ancient humans, The Fallen is confronted by the other Primes, who defeat and imprison him before he can harvest the planet’s Sun with the Matrix of Leadership. The Primes then sacrifice themselves to hide the Matrix in an unknown location shortly afterwards.
Two years after Megatron’s defeat, the Autobots join the U.S military to form the Non-Biological Extraterrestrial Species Treaty (NEST), a classified multinational task force hunting down the surviving Decepticons, led by William Lennox and Robert Epps. During a mission in Shanghai, Optimus Prime is warned by Demolisher of The Fallen’s return. National Security Adviser Theodore Galloway scolds the task force sarcastically for their tactics, reminding them that Megatron’s corpse is still resting at the bottom of the Laurentian Abyss and the last known AllSpark shard is locked up in the NEST’s headquarters. Simultaneously, Soundwave hacks into a U.S. military satellite, overhears the information, and sends Ravage to retrieve the shard.
Meanwhile, Sam Witwicky prepares to attend college, leaving his girlfriend Mikaela Banes and guardian Bumblebee behind. While preparing, he discovers a smaller AllSpark shard in his jacket. He picks up the shard, which causes him to see Cybertronian symbols and unexpectedly brings kitchen appliances to life. After Bumblebee destroys the rampaging appliances, Sam gives the shard to Mikaela, who later captures Decepticon Wheelie when he tries to steal it. The Constructicons resurrect Megatron by using the shard retrieved by Ravage and brutally ripping apart one of their own allies to provide parts for him. Megatron then travels to a moon of Saturn, where he reunites with his master, The Fallen, who orders him to capture Sam alive and kill Optimus, as Optimus is the last of the Primes and the only Transformer who can defeat The Fallen.
A pretender Decepticon, Alice, tries to seduce Sam, until he gets rescued by Mikaela and his college roommate Leo. They are then captured by the Decepticons and are brought to an abandoned factory. Megatron reveals that the symbols in Sam’s mind will lead the Decepticons to a new Energon source before Optimus and Bumblebee arrives to rescue the trio. Optimus engages Megatron, Starscream, and Grindor; though Optimus injures Starscream and kills Grindor, Megatron kills him by impaling him through the chest, damaging his spark. The other Autobots then arrive and repel the Decepticons, forcing Megatron and Starscream to retreat. Afterwards, the Decepticons launch an international assault on many areas around the world simultaneously. The Fallen hijacks Earth’s telecommunications systems, demanding Sam to be turned over to him.