During the final days of the war that devastated the planet Cybertron, a spacecraft known as The Ark attempted to escape. Piloted by the great Autobot leader named Sentinel Prime (Leonard Nimoy
), the ship was said to contain special items that could help the Autobots win the war over the Decepticons. However, the ship was hit by enemy missiles, and the ship and its crew were lost into the far reaches of space.
In 1961, the crash of the Ark on the moon is detected by NASA. Fearing that the Russians may beat them to finding out what this unidentified object is, President John F Kennedy pushes for NASA to land men on the moon to investigate. 8 years later, in 1969, Apollo 11 lands on the moon, and astronauts Neil Armstrong (Don Jeanes
) and Buzz Aldrin (Cory Tucker
) secretly explore the craft. They return with samples and pictures, and future moon missions bring back more information, before the manned moon missions are cancelled.
In the present day, The Autobots are still working with the NEST Team to track down Decepticons loose on the planet, as well as anything unusual. While the Autobots Bumblebee, Sideswipe, Enzo, and Que attempt to take out an illegal Middle-Eastern nuclear plant, Major Lennox (Josh Duhamel
) is informed by a Ukranian official, Alexi Vokshod, about something strange going on around the Chernobyl disaster site. Lennox leads a team along with Optimus Prime (Peter Cullen
) and Ratchet (Robert Foxworth
) into the radioactive site. Inside the plant, Prime discovers a fuel cell from the Ark, and something even more shocking: the Decepticon Shockwave (Frank Welker
) and a giant drilling robot at his command. After a short fight, Shockwave and the driller retreat. During the battle, a Decepticon assassin, Laserbeak (Keith Szarabajka
), ambushes Vokshod kills him.
Eventually, Prime and the other Autobots return to NEST's headquarters. Once there, Optimus demands answers from Secretary of Defense Charlotte Mearing (Frances McDormand
). Prime shows the recovered fuel cell, and Mearing admits the true intentions of the American rush to reach the moon in the 1960's. Wishing to investigate further, Optimus and Ratchet take a ship (that had been used by other Autobots who now make Earth their home as well) to the moon, and inspect the Ark. In a secret chamber, they find the weakened body of Sentinel Prime, as well as 5 metal 'pillars'.
Megatron (Hugo Weaving
) is hiding in Africa, still sporting battle damage from his last fight with Optimus Prime. Starscream (Charles Adler
), Laserbeak, and Soundwave report to him, telling him that Optimus has recovered Sentinel Prime and the pillars. Megatron tells Soundwave that their human collaborators have served them well, now it is time to clean up loose ends.
Meanwhile, Sam Witwicky (Shia LaBeouf
) has graduated from college. Even though he has been instrumental in helping the Autobots (which is classified information) and received a Medal of Honor from President Barack Obama, he is still unable to find a job. Sam currently resides in Washington D.C. with his new girlfriend Carly Spencer (Rosie Huntington-Whiteley
), and two smaller Autobots named Wheelie (Tom Kenny
) and Brains (Reno Wilson
). Eventually, Sam lands a job with Accuretta Systems, a technology firm run by an eccentric man named Bruce Bezos (John Malkovich
). Though Sam came highly recommended (by an unnamed person), Bezos explains that the only position they are hiring for is the company's mail room. Sam is about to turn down the position, but Bezos convinces him it is a necessary first step toward the job he really wants.
Sam then goes to visit Carly at her place of work, where he runs into her accountant (and car-collecting) boss, Dylan Gould (Patrick Dempsey
). Sam is easily jealous and ticked off by how close Dylan seems to be to Carly. As if to add insult to injury, Dylan gives Sam an aside that he was the one who recommended Sam to Accuretta (at the insistence of Carly to help him out), as he is one of its senior board members. Soon afterwards, Dylan invites Carly to a social function at his place, and even gives her a brand-new Mercedes SLS AMG (further ticking off Sam).
No sooner does Sam start his job, then he is accosted by an excited co-worker named Jerry Wang (Ken Jeong
). Jerry corners Sam and gives him a number of papers and news clippings, talking about the 'Dark Side of the Moon' and that the Autobots are in danger. Sam peruses through the clips, but before he can get more information, Jerry plunges to his death out his office window. A few moments later, Laserbeak transforms from a nearby copier, and attempts to kill Sam.
Sam manages to escape, and drives to the 'Department of Health and Human Services' where NEST is secretly stationed. The Autobots and Lennox allow Sam and Carly clearance into the facility, but Mearing is not at all happy. Sam attempts to tell Mearing about Jerry's death and the notes he passed to Sam, but Mearing refuses to listen to him.
Also at the base, Prime and Ratchet have returned with the body of Sentinel Prime. Using the Matrix of Leadership, Optimus manages to revive Sentinel. At first disoriented, Sentinel soon demands to know about the pillars. When the group tells him they found five, Sentinel claims there were more. He is further upset when Mearing tells him that the five they recovered are locked away from him for security reasons. When Sentinel explains they could be used to open a bridge through space and time, Mearing grows even more uncertain about returning them.
Bumblebee is allowed to escort Sam home for protection, but Sam feels that there's something going on that they should investigate. Having copies of Jerry's notes, Sam puts in a call to Seymour Simmons (John Turturro
), who has since written a book about his exploits, and hired a retired NSA agent, Dutch (Alan Tudyk
), as an assistant. Though claiming he has sworn off getting involved in the affairs of the Transformers, Sam's request and the promise of unknown Transformers information sends Simmons right to Sam's doorstep.
Optimus gives Sentinel a tour of Earth. As they watch a sunset in Washington, DC, Sentinel marvels at the planet's beauty, reminding him of Cybertron before the war. Optimus offers to relinquish the Matrix to Sentinel, but is politely rebuffed. On this new, unfamiliar planet, Optimus is now Sentinel's teacher.
Perusing over Jerry's notes, it soon becomes apparent that a number of people who had some involvement with the cover-up of the Ark on the moon are either missing or have died mysteriously. Carly soon finds out about Sam's investigations, and expresses her disdain for Sam possibly getting into harm's way. She has already lost her Brother to the war involving the Transformers, and this explains her distaste for what he is doing. Sam claims he is doing this because it is important, but Carly leaves for her meeting with Dylan at his mansion.
Shortly thereafter, the investigation reveals that there were several planned moon missions to be made by Russia, but they were mysteriously cancelled. Sam, Simmons, and Dutch track two of the defected Cosmonauts to a seedy bar. After some discussion, they explain that before the Americans landed on the moon, satellites that took photos of the moon revealed strange tracks and stacked objects. The classified photos reveal stacks of pillars like the five recovered with Sentinel Prime.
Sam soon realizes that Wang's conspiracy theory is true. The Decepticons needed Sentinel Prime to activate the pillars. They stole what they could, but left five (including the Master Pillar that controls them) with the weakened body of Sentinel, planting clues to lead the Autobots to him and revive him, most likely planning to bring an invasion force to Earth!
Sam and the other Autobots manage to find Sentinel and help escort him back to NEST for safety. However, the group is menaced by three black SUV's that turn out to be three beast-like Decepticons known as The Dreads. The group manages to destroy them, and return to the base. It is then that Sentinel shockingly reveals that long ago, he had made a deal with Megatron to end the war and rebuild Cybertron. He then shocks the others by killing Ironhide, as well as destroying NEST's base and making off with the five pillars. Optimus returns soon afterwards, with Mearing blaming him for what has happened.
Sentinel joins Megatron and Starscream at the Lincoln Memorial. While Sentinel aligns the pillars in the reflecting pool, Megatron explains to Starscream that Sentinel was actually defecting when he left Cybertron. Megatron had planned to rendezvous with him after recovering the Allspark, but "fate waylaid them both." Optimus arrives in an attempt to stop Sentinel, but is easily overpowered and forced to retreat. As Megatron claims the Lincoln Memorial as his throne, Sentinel activates the spacebridge. One on the moon activates as well, and numerous Decepticons and aerial combat craft emerge, running about and even disguising themselves like nearby vehicles.
Fearing for Carly's life, Sam returns to their place, only to find her gone. Remembering that she was going to Dylan's mansion, Sam shows up there, but is shocked when Dylan reveals that his Dad was a previous accountant that fixed the books at NASA, preventing further moon landings. Realizing that he's somehow connected to the Decepticons and their plans, Sam attempts to drive Carly away, only for her Mercedes to transform into Soundwave, who locks her inside him! Sam is menaced by Laserbeak and Dylan, who has a Decepticon in the form of a watch attach itself into Sam's wrist. Sam is given an ultimatum: find out for Dylan and the Decepticons how Optimus intends to fight back, or Carly will die.
Sam is soon after contacted by Mearing, who apologizes for doubting him previously. After they meet, the United Nations receives a voice-encoded message from Sentinel Prime, demanding that the humans exile the Autobots from Earth. The demands are met, and Optimus and the remaining Autobots are taken to Florida to be flown away. While there, Sam meets former Chief Epps (Tyrese Gibson
), who has been working with the Autobots known as The Wreckers to prep the shuttle for their departure.
As the Autobots prepare to leave on the shuttle Xantium, Sam attempts to secretly warn Optimus, claiming that he knows Optimus has a plan, and that 'no human will ever know' if he tells him (Sam). Optimus claims they have no plans to fight back, and Bumblebee says his goodbyes to Sam as well.
The next day, the Xantium takes off as Sam looks on from nearby. However, Starscream has been lying in wait in the upper atmosphere, and shoots down the rocket. The destruction of the Autobots causes the Decepticon watch on Sam's arm to slither away. Sam soon receives a call from Dylan, who is pleased that the Autobots are now out of the way. After Dylan hangs up, Sam gets ahold of Simmons and Dutch, they pinpoint that Dylan has taken Carly to Trump Tower in Chicago, IL.
Sentinel Prime, Megatron, and Starscream also arrive in Chicago, and take control of the top of a building, where Sentinel plants the pillars with Dylan's help. Dylan reveals to Carly that the Decepticons intend to rebuild Cybertron, strip-mining the earth for resources and using humans as slave labor. In order to do this, the Decepticons have placed Pillars around the world to call Cybertron itself through the space bridge, with Sentinel planning to activate the control Pillar at a specific time. Carly witnesses a crack in the fragile alliance, as Sentinel angrily reminds Megatron that he is an ally, not a minion.
Shortly thereafter, the Decepticons and an army of ships and weaponry descend upon Chicago, destroying much of the city, and creating a heavily fortified perimeter keeping any armed forces from getting inside. Sam still intends to rescue Carly, and Epps along with several disbanded NEST team members accompany them to the outskirts of Chicago. They are almost vaporized by an attack drone, until the Autobots appear and take it down. The group reveals that they secretly hid in one of the booster rockets that detached from the Xantium and fell into the ocean before Starscream blew up the main craft. They laid low to make the Decepticons think they had left.
Bumblebee pilots the downed drone, while the Autobots drive into the city. Sam manages to rescue Carly from Dylan's penthouse, killing Laserbeak in the process, but the group is then faced with the task of taking stopping Sentinel Prime. It doesn't help that Dylan has also alerted the Deceptions of the Autobots survival. Megatron orders all available troops to protect Sentinel while he aligns the final pillars. Optimus and the other Autobots attempt to create a diversion, while Sam, Carly, Epps, and the NEST agents attempt to use a rocket launcher to take out one of Sentinel's pillars. Que also provides Sam and the NEST agents with some special devices he's been working on.
They take aim in a heavily-damaged office building, but are unable to finish their plan as Decepticon drones and their pilots attempt to bring down the building, along with Shockwaves' 'pet' drilling robot. The group is saved when Prime (outfitted with accoutrements from his trailer) flies in and destroys the giant drill-bot.
Meanwhile, using a drone, Lennox is able to communicate with the group, and he and several of his men fly into the danger zone with 'squirrel-suits,' allowing them to jump out of transport carriers and glide through the city. The group manages to catch up to the others as Sam ends up destroying Starscream with several of Que's gadgets.
They then regroup near an area where several Decepticons (including Soundwave) have captured Bumblebee, Ratchet, Que, and Dino. Dylan is also nearby, claiming that taking hostages was not part of their deal, he wants the Autobots to suffer for disrupting what should have been a peaceful process. Soundwave agrees and decides to execute the hostages. Barricade kills Que before Soundwave takes aim at Bumblebee. However, the group is distracted when drone ships begin raining down from the sky. Wheelie and Brains have managed to get into one of the main ships, jettisoning its cargo as it crashes into the Chicago River. At this point on, Bumblebee kills Soundwave after overpowering him in a fight.
The Autobots and the NEST agents are soon joined by some Navy Seals, Together, they destroy some Decepticon Protoforms and they end up killing Barricade as well. As they watch Sentinel activates the Master Pillar, activating the other spacebridges placed throughout the Earth. As everyone watches, Cybertron begins to materialize in Earth's upper atmosphere. Soon after, Optimus swoops in and destroys the ground troops. After dodging the decepticon's poor aim, Optimus Prime kills Shockwave before using his cannon to blow up one of the pillars, causing the spacebridge to disengage. Sentinel drops to the ground, and begins to battle Prime, before calling for reinforcements, all of which are destroyed by some human allies.
Megatron, sitting in a throne of junk in the side alley, wearily sighs that Cybertron is safe when Carly finds him. Having witnessed the previous argument between Megatron and Sentinel, Carly convinces Megatron that he will answer to Sentinel Prime once Cybertron is restored, instead of leading the Cybertronians himself.
Sam has managed to reach the downed Pillar, but is confronted by Dylan, who reactivates it, causing Cybertron to continue reforming in the atmosphere. Eventually, Sam knocks Dylan out, causing him to get electrocuted by the pillar before Bumblebee takes it out. This causes the partially-formed planet above to be sucked into a vortex, pulling the numerous Cybertronian ships and drones into it.
Optimus engages Sentinel in a battle. Sentinel soon gains the upper hand and Optimus loses his arm before being knocked down by the older prime, Sentinel prepares to kill Optimus when all the sudden, Megatron saves Optimus and damages Sentinel, having listen to Carly's words and declaring that this plant is his to rule. Megatron proposes a truce between him and Optimus, but the Autobot leader will have none of it, too many have died because of him. Megatron then attempts to shoot Optimus, but the battle between them is quickly finished as Optimus rips Megatron's head and spine from his body, killing him.
In the aftermath, a weakened Sentinel claims that he was only thinking about saving their race, and did not mean to betray them. Prime claims that Sentinel betrayed himself, and shoots him as the old Prime pleads for mercy, killing Sentinel.
As the NEST agents and the Autobots gather, Sam embraces Carly, and with all chances of ever reviving or returning to Cybertron gone, Optimus realizes that the Autobots' only home from now on will be Earth.