In the present, the Autobots assist the US military in preventing conflicts around the globe. During a mission to Chernobyl to investigate suspected Alien technology, Optimus Prime finds a fuel cell from the Ark, discovering it had survived its journey from Cybertron. The Autobots are attacked by Shockwave who manages to escape. After learning of the top-secret mission to the moon, the Autobots travel there to explore the Ark. There they discover a comatose Sentinel Prime — former Autobot leader — and his creation, The Pillars, a means of establishing a Space Bridge between two points to teleport matter. After returning to Earth, Optimus uses the energy of his Matrix of Leadership to revive Sentinel Prime.
Meanwhile, Sam Witwicky is frustrated that he is unable to work with the Autobots and failing to find a job. He also becomes envious of the close relationship between his new girlfriend, Carly Spencer, and her boss Dylan Gould. After finding work, Sam is provided information by his co-worker Jerry Wang about the Ark before he is assassinated by Laserbeak — a condor-like Decepticon. Sam contacts the now-retired Seymour Simmons, and together they realize that Megatron and the Decepticons are murdering people connected to the American and Russian space missions to the Ark. They locate two surviving Russian cosmonauts who reveal satellite photos of hundreds of Pillars being stockpiled on the moon. Sam realizes that the Decepticons raided the Ark long before the Autobots mission and intentionally left Sentinel and five Pillars behind to lure the Autobots into a trap - Sentinel being key to activating the Pillars and the Decepticons lacking the means to revive him. The Autobots rush to return Sentinel to their base for protection but Sentinel betrays them and kills Ironhide, revealing he had made a deal with the Decepticons to ensure the survival of the Cybertronian race.
Sentinel uses the Pillars to transport hundreds of concealed Decepticons from the moon to Earth and Carly is captured by Gould, who is revealed to be in the Decepticons' service. The Autobots are exiled from Earth at the demand of the Decepticons to avoid war but as their ship leaves Earth it is destroyed by Starscream, seemingly killing the Autobots. The Decepticons, led by Megatron and Sentinel, seize Chicago as their agents place Pillars around the world. Gould reveals to Carly that the Decepticons plan to transport their homeworld of Cybertron to the Milky Way to use the resources and enslaved humans of Earth to rebuild their world. Sam teams with Robert Epps to go into Chicago and save Carly, but they are nearly killed by Decepticon forces before the Autobots intervene; revealing they concealed themselves during the launch of their ship to convince the Decepticons they were destroyed.
Working together, the Autobots and human soldiers manage to rescue Carly and destroy Soundwave, Barricade, Starscream and Shockwave with Optimus using Shockwave's arm-cannon to blast the Control Pillar, disabling the Space Bridge. Sam confronts Gould as he reactivates the Control Pillar. Sam knocks Gould into the Pillar, electrocuting him. Bumblebee and Ratchet arrive and destroy the Control Pillar, permanently disabling the Bridge and causing the partially transported Cybertron to implode. Optimus and Sentinel fight while Carly convinces Megatron that he will be replaced as leader of the Decepticons by Sentinel. Sentinel severs Optimus' right-arm and prepares to execute him when Megatron intervenes, incapacitating Sentinel. Optimus attacks Megatron, decapitating and killing him. Sentinel pleads for his life but Optimus executes him. With the Decepticons defeated, Carly and Sam are reunited and the Autobots accept that with Cybertron gone, Earth is now their home.