NOTE: This spoiler was submitted by L

Optimus Prime states in a monologue that the fates of Cybertron (home world of the Autobots and Decepticons) and Earth have been interlocked for longer than either race could have suspected. The earliest Autobots had visited Earth millennia prior to the first film. A scene from 17,000 BC shows The Fallen attacking primitive tribesmen around Egypt, as Autobots and Decepticons fight among a Cybertonian Object.

Cut to present day Shanghai. Capt. Lennox (Josh Duhamel) and his team, N.E.S.T, are pursuing two Decepticons through the city. A giant Constructicon called Demolisher and a silver car flee the scene. Capt. Lennox calls in Ironhide, Sideswipe, The Twins (Skid and Mudflap), Jolt and Arcee to help take them down. Ironhide splits the silver Decepticon car in half as it reaches an alleyway but the Constructicon escapes the initial dragnet. Sgt. Epps (Tyrese Gibson) calls in Optimus Prime to finish it off before it can total all of Shanghai. A giant freight plane carries Optimus over Shanghai and Optimus parachutes down. He transforms into his truck mode and pursues Demolisher through the city before transforming again and jumping on it. He blasts it off the road and the military surrounds it. Demolisher looks at Optimus and tells him, “This planet is not yours to rule over. The Fallen will rise once again.” Optimus tells him “Not while I’m around.” and shoots Demolisher in the head, killing it. Sgt. Epps and Capt. Lennox wonder what the warning means. Meanwhile, Soundwave, a Decepticon Intelligence Officer hijacks a U.S. Satellite to listen in on encrypted conversations between the military and N.E.S.T.

Sam Whitwicky (Shia Lebouf) is ready to go to college. As he starts to load the car, his mother Judy cries about how she is losing her precious baby while Sam’s father, Ron, is excited since he is taking his wife to Paris so they can reignite their romance. Sam is disgusted by this, but Ron tells Sam that it’s part of life. Ron reminds Sam that in college, everything changes. He makes a point to tell Sam that he may even end up with another girl instead of Michaela (Meghan Fox). Sam tells Ron that he’s a one-woman kind of guy as Michaela calls. She tells him she’s dumping him so she won’t have to say goodbye to him when he leaves.

Sam takes the conversation inside his house and reminds her of all the fun times they had since their first adventure two years ago. They fool around on the phone a bit and Sam tells her seriously that there are cheap apartments near his college where Michaela could live. Michaela tells Sam that since she is looking after her recently released ex-con father, that can’t happen. Sam successfully deflects Michaela’s halfhearted attempt to break up with him and convinces her to come see him off to college. However, as he goes through his old clothes, a shard of the All Spark (the power source of the Autobots and Decepticons from the first film) falls out of the sweater he wore when he killed Megatron. Sam picks up the shard, which activates and causes Sam to have flashes of ancient Cybertonian symbols. The spark burns a hole through the floor and turns all the kitchen appliances into mini Decepticons.

Sam struggles to put out the fire in his room before he is attacked by the kitchen transformers. Sam jumps out of his window and drags Ron behind their fountain in order to get cover. Sam calls on Bumblebee to defend them and Bumblebee ends up destroying half the house. Judy freaks out but Ron tells her that the government will pay for the remodeling. Judy tells Sam that Bumblebee needs to leave. Michaela arrives and asks what happened but Sam brushes the question off and gives her the shard of the All Spark to hide. Unbeknownst to them, Wheelie, a Decepticon who transforms into an RV has tracked the pulse and starts following Michaela. Sam tells Bumblebee that he can’t bring him to college with him since freshmen aren’t allowed to have cars. Bumblebee is upset, but accepts it. Michaela and Sam share a moment together before the Whitwickies leave for college.

Sam moves into her dorm and meets his new roommate, Leo Spitz (Ramon Rodriguez). They share that “moment” where they see if they are both normal and can be relied on. Leo shows Sam that he runs an alien conspiracy website which focuses on Transformers activity, which world leaders have been covering up for the past two years. Leo’s main competition is a site run by “Robowarrior”, a user who owns his own Transformers based site. Sam and Leo get off on the wrong foot and Sam asks for a room switch. However, this is denied so Sam deals with it. He runs into Judy, high off of pot brownies she mistook for all natural brownies, telling girls about how she heard Michaela take Sam’s virginity a few weeks earlier. Sam and Ron take her back to the car and the Whitwickies part ways.

Back at N.E.S.T Headquarters, Optimus Prime and Capt. Lennox debrief General Morshower (Glenn Morshower) on the activities of the Decepticons around the globe for the last two years. The Decepticons have been looking for something, but they have no idea what. National Security Advisor Galloway (Benjamin Hickey) wants to banish all the Autobots from Earth since he feels that they are the reason the Decepticons are still on Earth. Optimus tells Galloway that if asked to leave, the Autobots will do so but cautions Galloway as to the detrimental effects it would have to the human race if his theory is incorrect. Soundwave listens to all this and discovers where another shard of the All Spark is being held in N.E.S.T headquarters and where Megatron’s body is located. Soundwave sends Decepticon Ravage to infiltrate N.E.S.T and recover the shard of the All Spark. Ravage successfully steals the shard from its maximum-security vault and leaves.

At the Lorentian Abyss, a submarine is surveying Megatron’s grave when 5 Decepticons go underwater and recover Megatron. They use one of the other Decepticon’s Sparks (The Life Force of All Autobots and Decepticons) to ignite Megatron’s and, resurrected Megatron and company fly off to the Decepticon base. Megatron is pissed that Starscream left him to die in the last film, but instead of killing Starscream, he goes over to The Fallen and apologizes for the destruction of the All Spark. His master tells Megatron that if they take care of Optimus Prime, The Fallen will be able to re-conquer Earth using an alternative source of Cybertronian energy hidden on the planet. The Fallen makes a point of saying that he cannot return to Earth until the last Prime is dead, since only a Prime can successfully kill the Fallen, who used to be a Prime before creating the Decepticons.
That night, Michaela and Sam are supposed to have their first web chat date. Unfortunately, Leo drags Sam to a frat party where a mysterious girl named Alice (Isabel Lucas) watches Sam from afar. While looking at a symbol on a cake, Sam has flashes of the Symbols and starts drawing them with frosting. Alice watches this with interest and begins hitting on Sam. Sam tries to get away, and successfully does so when Bumblebee arrives at the party. Sam gets in the car, but Alice does as well. Bumblebee dislikes Sam being with another woman and sprays Alice with gunk. She leaves in a huff after acting in a peculiar manner.
Bumblebee takes Sam to a graveyard where he meets with Optimus Prime. Optimus tells Sam that Galloway wants to send the Autobots away and asks Sam to be their ambassador to the world leaders. Sam tells Optimus that he’s just a random kid and isn’t important. He tells Optimus that he’s not a part of their war and leaves. Optimus says that Sam is more important than he realizes.
During his first class, Sam listens to his sleazy Astronomy teacher, Professor Colan (Rainn Wilson) give his opening lecture and hit on some of the younger women in the class. Sam starts seeing the symbols and then reads through his 894 page textbook in a minute. He interrupts the class and tells Colan it’s all wrong and writing complex calculations on the board before being kicked out of the class. Realizing that the Spark infused Cybertonian knowledge into his brain, he calls Michaela. Michaela is pissed she got stood up on a webcam date, but Sam tells her that she SHOULD NOT touch the Spark. She tells him that she put it in the Auto shop safe, before finding Wheelie trying to steal it. She burns out one of his eyes and locks him in a box. She books a flight out to the University and brings Wheelie and the Spark with her.

Alice asks Leo if Sam is in their room. They arrive and see that Sam has painted the Symbols from his mind on the walls. Alice throws Leo out and pushes Sam onto the bed and kisses him. As she does a Decepticon tail slithers out of the back of her dress and is ready to stab Sam when Michaela walks in. Not noticing the tail (it disappeared), Michaela just thinks Sam is cheating and storms off. Sam tries to pursue but Alice reveals herself to be a Pretender (a Decepticon taking Human Form) by wrapping her 8 foot metal tongue around Sam and tossing him around the room. Leo and Michaela return upon hearing the commotion and Sam breaks free. The trio then run as “Alice” launches a full scale attack on the dorm in an effort to capture and neutralize Sam.

The trio runs through the quad and into the library in order to get away from the Pretender. “Alice” blows up most of the library and the trio jump out of a hole created by the blast. In the parking lot, Michaela hotwires a car so they can drive away. “Alice” arrives (a la Terminator) and punches a hole in the windshield. As she starts transforming, Michaela crashes the car into a tree, effectively crushing the Pretender to death. Unfortunately, Grindor, a Decepticon helicopter, captures the car and brings it to a large warehouse where Starscream and Megatron are waiting.

The car is dropped into the warehouse and quickly cut in half. Starscream separates Sam from Michaela and Leo, and the group is reintroduced to Megatron. Megatron forces Sam onto a table and has a small robot forced into Sam’s brain orally. Images of the symbols in his mind are projected and Megatron realizes that it is a map. Before Megatron can rip out Sam’s brain to steal all the information and avenge his death from the first film, Bumblebee and Optimus Prime arrive to rescue their captured allies.

Optimus retrieves Sam and drives off with him while Bumblebee takes Michaela and Leo safely away from the warehouse. Megatron, Starscream and Sideways pursue Optimus and Sam to a forest. There, Optimus single handedly fights all three Decepticons. He kills Sideways and cuts off Starscream’s arm during the fight, until Megatron stabs Optimus through the heart with a battle axe.  Optimus collapses, dying and tells Sam to run. His spark gives out and Optimus dies. At that moment on Saturn, The Fallen is reenergized, celebrating the death of the last Prime. Sam runs from the scene as the other Autobots arrive to fight off Megatron and Starscream to recover Optimus’ body.
Bumblebee and the Twins drive to a safe location with Sam, Leo and Michaela. Meanwhile, Megatron and Soundwave broadcast a message from the Fallen directly to everyone on the planet. The Fallen tells them that their leaders have kept the existence of Autobots and Decepticons from them for a while. He tells them that if they do not hand over Sam Whitwicky, they will all die. This begins a global manhunt for Sam and the last two people he was seen with: Michaela and Leo.
Decepticon pods land all over the Earth. Ravage arrives in Paris and captures Ron and Judy as part of a trap to lure Sam out into the open.

In the wake of Optimus’ death, Galloway suspends N.E.S.T for decommission and orders that all the remaining Autobots be shipped back to base before they are ordered off the planet. Capt. Lennox disagrees and is subsequently removed from leading operations by Galloway. The Autobots load up Optimus’ body and accept Galloway’s decision.

Leo is freaking out over his status as a fugitive but Sam tells him to shut up since Leo is now getting the full truth about the aliens. Leo composes himself while Sam talks to Michaela and Bumblebee about turning himself in. Bumblebee tells him that doing that would undo everything Optimus died for. Sam remembers that Megatron told him that there was a map in his head, so he draws the symbols and asks the Twins if they can read it. They can’t, but Leo says he knows someone who can: his sworn enemy and rival, “RoboWarrior” Since Leo once revenge hacked RoboWarrior’s site, he knows that “RoboWarrior” works in a deli in New York.

“RoboWarrior” is revealed to be none other than Seymour Simmons (John Tuturro), former leader of the now defunct Sector Seven, and now a butcher at his mother’s deli. At first unwilling to help Sam, he has a change of heart when Sam tells him about the symbols and Megatron’s revival. Simmons takes Sam down into his secret base of operations and shows him files which indicate that the Transformers have been on Earth for years, looking for something. While there were infinitesimal amounts of their radiation present around the globe, Simmons’ superiors all brushed him off as an obsessed lunatic. However, Simmons found symbols carved into ancient ruins all over the world and linked them to the Autobots and Decepticons. Simmons tells them that without being able to ask a Decepticon, they won’t learn anything else. Michaela runs and recovers Wheelie from his box and they coax him into giving them information. Wheelie cannot read the symbols He identifies several old Transformers in photos and indicates where they are currently residing on a map. The closest one is in the Museum of Aviation in the Smithsonian.

The group arrives at the Smithsonian and hunt for the robot. Wheelie, a radiation detector and the shard of the All Spark all lead to an old Jet Fighter on display. Wheelie tells Sam how to use the All Spark shard to wake it up and Sam does so. However, Michaela notices that it has the Decepticon logo and the group flips as Jetfire awakens. Jetfire storms out of the Museum and is “on a mission.” He explains that he was tasked to find “The Matrix of Leadership”, the energy key to a device which harvests and destroys suns to produce the energy needed for Cybertronians to successfully reproduce. The Thirteen original Transformers sought out suns to power their system but would never use it when the sun was powering a life based planet. However, upon arriving on Earth, the Fallen tried to use the machine despite his brothers’ protests. They banded together and fought the Fallen, stealing the Matrix and sacrificing themselves to keep it hidden. The Matrix is hidden in the Tomb of the Primes which is somewhere in the Egyptian desert. If they knew a Prime it would be easy to find the Matrix. Jetfire has always wanted to meet a Prime and asks if there are any on Earth. Sam tells them that Optimus, the last of the Primes, died protecting him. Jetfire tells him that the Fallen had driven him crazy with all his yelling about destroying Earth, so Jetfire had unofficially joined the Autobots. He tells them that he will help them find the Matrix.

Jetfire teleports the humans, Bumblebee and the Twins to Egypt. Sam’s hand gets horribly burned during the teleportation but everyone else is unharmed. Simmons yells at Jetfire and Sam asks how they are going to find the Matrix in the middle of the desert. Jetfire tells Sam that the map is in his mind and tells Sam a riddle which would help him find it. Before they leave, Sam asks Jetfire if the Matrix could be used to jumpstart the Spark of a dead Autobot. Jetfire doesn’t know but tells Sam it’s worth a shot.

The group figures out the coordinates of the Matrix and travel all the way to Jordan. Once they cross the border, Israeli authorities become aware of Sam’s presence and begin a hunt for him in accordance with the Fallen’s wishes. Simmons calls Lennox and tells N.E.S.T that there is “a possible resurrection in the works for the truck” and gives Lennox coordinates for where the drop point should be. Sgt. Epps is skeptical about all this but they give the coordinates to the pilots and fly off with Galloway on board.

The group arrives in Petra and the Twins start fighting over why they should be helping Sam. As they fool around, they break part of the wall. Bumblebee pissed that they’re questioning their allegiance to Sam, throws them out on their asses. Sam notices the hole and has Bumblebee blast a hole into the tomb of the Primes. Sam touches the Matrix but it turns to dust. The others think it’s all been for nothing, but Sam knows there has to be a reason they’re all here. He puts all the dust into an old sock. Simmons asks if he thinks he can revive Optimus with the “pixie dust”, and Sam leads the group to where they’re supposed to meet the troops.

N.E.S.T is on route to the drop zone, but Lennox is aware that Galloway could pose a hazard to the operation. He tricks Galloway into parachuting off the airplane a couple of hundred miles away from the site. The N.E.S.T team parachute out along with Optimus’ body and the rest of the Autobots. They secure the area but see the Decepticons arriving off in the distance. Sam now has to run approximately 5 miles through a city being heavily searched by Decepticons led by Megatron. Simmons and Leo notice that a Constructicon called Devastator has come together near the Pyramid. They stay behind with the Twins in order to take it out. Sam and Michaela go it alone with Bumblebee providing them cover from the other Decepticons.

As the teens race through the city, Lennox and his team fire at the Decepticons. Megatron orders Ravage to spring “the trap” and Ravage dumps Judy and Ron into the city. Sam runs by and notices them before being cornered by Ravage and Overload. Sam offers them the dust in exchange for his parents safety before noticing Bumblebee crouched behind a corner. Bumblebee attacks and fights both Decepticons. Ravage jumps on Bumblebee but Bumblebee rips his metallic flesh from his spine easily before blowing Overload’s head off. With Sam’s parents rescued, Bumblebee takes them to safety behind the lines of Lennox’s team. Sam continues running through the city with Michaela. Megatron, aware of what is happening, sees Sam running toward the cover of Lennox and his troops.

Israeli air support arrives to help Lennox’s team but Starscream shoots them down. One chopper lands near Simmons and Leo as they deal with Devastator. Mudflap gets sucked into Devastator’s mouth and then blows his way through Devastator’s head. Devastator ignores the twins and climbs the nearest pyramid, which is revealed to be the Sun Harvester the Cybertonians would use to charge the All Spark and destroy suns. Simmons uses his radio to call in a favor from a sea captain testing a very experimental laser cannon.

Sam reunites with Lennox and Epps just as the firebombing begins. Epps, Michaela, Sam and Lennox run for cover as the bombs begin to fall. However, just after they clear the blasts, Megatron arrives and shoots Sam in the back with his laser before the military use their tanks to fire on him. Megatron flees after killing Sam.

Michaela is devastated that Sam is dead and tells him that she loves him and that he needs to come back. Ron and Judy arrive with Bumblebee and are horrified to see their son dead. A medievac chopper arrives and the medics try to revive Sam. However, it’s no good.

Simmons and Leo watch from the ground as a large laser shoots through Devastator, destroying it completely. However, the tip of the pyramid was destroyed and reveals part of the Sun Harvester’s top.

The Decepticons continue their attack on the military with Scorponok running point. However, Jetfire teleports and tears some Decepticons apart with his battle axe. Scorponok rips out part of Jetfire’s chest, exposing his Spark before Jetfire rips Scorponok in two. Jetfire sees the bodies of Optimus and Sam and watches in interest.

Sam wakes up in a twisted ethereal world surrounded by the original Primes who sealed away the Matrix. They tell Sam that the Matrix was a test to see if Sam had the abilities of a leader. In fighting for Optimus and never giving up, the Primes give Sam a gift: his life. Sam jolts back to life after the medics leave and sees the Matrix, fully formed on the ground. He tells Michaela he loves her and hugs his parents before running to Optimus’ body and stabbing the Matrix into Optimus’s spark.

The Fallen arrives and rips the Matrix out off Optimus’ chest and teleports to the pyramid. The Fallen activates the Sun Harvester and neutralizes all the tanks with his scepter. Optimus is alive, but starts to enter stasis lock. Jetfire rips out his own Spark and gives it to Optimus along with some of his old parts. Jetfire dies and Optimus gets an upgrade with which to fight Megatron and the Fallen.

Optimus flies to the Sun Harvester and fights Megatron and the Fallen. Megatron proves to be no match for Optimus and gets part of his face and his arm cut off. The Fallen and Optimus fight one on one, but Optimus easily overpowers him. Optimus rips off the Fallen’s face before stabbing him through the chest and taking The Fallen’s Spark. Defeated, Starscream and Megatron make a tactical retreat.

Sam and Optimus stand on a military ship as they ship back to America. Optimus tells him that their untold past unites them and that they will face the future together.
An after credit scene shows Sam returning to college and being welcomed back to his astronomy class. Professor Colan welcomes him back with a sarcastic “I’m glad Baby Einstein could grace us with his presence” to which Sam retorts “Yea, I’ve been a little busy.”