Transformers: Dark of the Moon begins in Cybertron. Sentinel Prime, Optimus Prime's mentor, pilots a spaceship called "The Ark", which contains technology that'd allow them to end the war, but it is damaged by Starscream and eventually crash-lands on the Moon in 1961.
The United States and the Soviet Union find out about it and the Space Race to reach the Moon and investigate the Ark begins. In 1969, the Apollo 11 crew arrives and explores the Ark, retrieving pieces of it and bringing them back to Earth for further studies. However, Sentinel Prime's body, now in Stasis Lock, is not found.
Today. Sam Witwicky and his new girlfriend Carly Miller are living in Washington, D.C., with two Decepticons-turned-Autobots, Wheelie and Brains. Sam's job application for NEST has been refused by the director of the National Security Agency, Charlotte Mearing, so he becomes a delivery boy at the firm of businessman Bruce Brassos. Carly is the personnal assistant of Dylan Gould, CEO of a major investments company.
Meanwhile, the Autobots are assisting NEST, led by Major William Lennox, in fighting human threats. Optimus Prime, Ratchet and Lennox head to Ukraine, where an engine booster from the Ark has been found by construction workers buried near Chernobyl. There, they are attacked by Shockwave, who is piloting the Driller, and retrieves the engine booster before returning to Africa, where Starscream, Soundwave and a weakned Megatron are hidden.
Optimus returns to America and confronts Mearing, who confirms that the Ark is in the Moon. The Autobots go there in a space shuttle provided by NASA and retrieve Sentinel Prime's body as well as part of the ship's cargo: Five Cybertronian pillars. Back on Earth, Optimus Prime uses the Matrix of Leadership to revive Sentinel Prime, who becomes a member of the Autobots.
At the firm, Sam meets Wang, an accountant who recognizes him from the Fallen's TV broadcasts and tells him that the Decepticons are using humans as pawns in a conspiracy. Laserbeak, who has been deployed by Soundwave, appears, kills Wang and tries to kill Sam, but is damaged and returns to Africa. Sam then heads to NEST's new headquarters, where he tells the Autobots about what happened. Mearing tells him to go back home, so Sam asks for the help of former Sector Seven agent Seymour Simmons, who has become a millionaire after writing a book about his experiences. Simmons and his assistant, Dutch, agree, but Carly becomes irritated that Sam is trying to save the world again and breaks up with him.
Sam, Simmons, Dutch, Bumblebee and Brains meet a group of Cosmonauts now living in America, who show them pictures of the Dark Side of the Moon filled with hundreds of Cybertronian pillars. They deduce that the Decepticons already knew about the Pillars and allowed the Autobots to revive Sentinel Prime because he is the key to using the pillars to activate a Space Bridge. At this moment, Ironhide, Sideswipe, Mirage and Sentinel Prime are attacked by the Dreads - Crankcase, Crowbar and Hatchet. With Bumblebee's help, they are defeated, but Sentinel Prime betrays the Autobots, kills Ironhide and escapes with the pillars.
It is revealed that Sentinel Prime decided that the Autobots would never win the war and decided to join forces with Megatron to teleport Cybertron to Earth's orbit, using Earth's resources and the humans as slave laborers to restore Cybertron before destroying the planet. Megatron awakens an army of Decepticons hidden on the Moon and they invade Earth through the Space Bridges, taking over the planet. The Autobots try to stop this, but are defeated by the Decepticons and forced to go into hidding.
Sam goes to Dylan's penthouse to find Carly, who went to a party there. Upon arriving, he discovers that Dylan is working with the Decepticons and Carly has been captured by Soundwave. Dylan forces Sam to spy on the Autobots, but Sam manages to warn Optimus of it. Sentinel Prime demands that the Autobots are exiled from Earth or the Decepticons will kill more humans. Earth's governments vote for them to leave. The Autobots head for Cape Canaveral, where they meet Robert Epps and the Wreckers Leadfoot, Topspin and Roadbuster, who modified the ship that brought Sideswipe's team to Earth, the Xantium, to allow the Autobots to leave.
As they're departing, Starscream appears and damages the Xantium, which crash-lands, seemingly killing the Autobots. Sam asks for Epps' help to rescue Carly and they go to Chicago, where the Decepticons have established a base. They manage to retrieve Carly, but are attacked by the Decepticons and chased to a building, where they attempt to shoot the main pillar of the Space Bridge, which is connected to Earth's magnetic core, before it opens the portal. Shockwave, piloting the Driller, attacks and destroys the building, just as the Autobots return alongside Lennox and his team.
Optimus destroys the Driller and then kills Shockwave. Meanwhile, Sentinel Prime humiliates Megatron before the Decepticons. Wheeljack gives Sam a power glove before being killed by Decepticons. Starscream kills Mirage and then chases Sam and Carly. Sam uses the power glove to damage Starscream and, with Lennox's help, they destroy him. Bumblebee kills Soundwave. Laserbeak is destroyed. Optimus destroys the pillar just as Cybertron begins to appear on Earth's orbit.
Optimus fight Sentinel and is badly beaten. Carly finds Megatron and tells him that Sentinel will destroy them the moment they stop being useful. Megatron, infuriated, helps Optimus to destroy Sentinel. They then talk about how the war has gone on for too long. Megatron no longer has dreams of conquering the Universe, he just wants his home back. Optimus allows him to return to Cybertron with the Decepticons and rebuild it, while the Autobots vow to stay on Earth. Optimus and Megatron become "brothers" again and Megatron leaves.
Meanwhile, Bumblebee gives Sam a ring which he uses to ask Carly's hand in marriage.
THE END.