Optimus Prime, leader of the Autobots, narrates the collapse of the Transformers' home world, Cybertron. It was rendered uninhabitable by war between the Autobots and the Decepticons. Led by Megatron, the Decepticons are searching for the AllSpark so they could use it to take over the universe. The Autobots want to find the AllSpark so they can use it to rebuild Cybertron and end the war. Megatron managed to locate the AllSpark on Earth, but crash-landed in the Arctic Circle and froze in the ice. After stumbling upon his frozen body in 1897, explorer Captain Archibald Witwicky accidentally activated Megatron's navigational system and his eyeglasses were imprinted with the coordinates of the AllSpark's location, an incident that left him blind and mentally unstable. Sector 7, a secret government organization created by President Herbert Hoover, discovered the AllSpark in the Colorado River and built the Hoover Dam around it to mask its energy emissions. The still-frozen Megatron was moved into this facility and was used to advance human technology through reverse engineering.
In the present day, the Decepticon known as Blackout attacks a U.S. military base in Qatar in order to find the location of Megatron and the AllSpark. He tries to hack into the files of the computer base but is stopped when the base commander cuts the computer hard lines. Captain William Lennox and his team manage to escape from the base and search for help. Back in the United States, Captain Witwicky's descendant Sam Witwicky buys his first car, which turns out to be the Autobot scout Bumblebee, who tries to help him woo his crush Mikaela Banes. Later, Sam catches a glimpse of Bumblebee's true form when he signals the other Autobots.
On Air Force One, another Decepticon named Frenzy infiltrates the plane and tries to hack into the network again, only this time is more successful until he is stopped by the U.S. intelligence operatives before he can retrieve the file information. Frenzy is then picked up by his partner Barricade, and they pursue Sam after discovering he has the glasses with the AllSpark's coordinates. Witwicky is rescued by Bumblebee, and Mikaela also learns of the Transformers' existence. Bumblebee fights Barricade and manages to subdue him while Sam and Mikaela decapitate Frenzy although he still survives and disguises himself as Mikaela's phone.
Meanwhile, Scorponok, who was sent by Blackout, fights Captain Lennox and his team, killing one of them and injuring another. During the battle, Scorponok is forced to retreat when he gets injured by sabot rounds fired on him by the U.S. Air Force. Lennox and his team then return to the United States and report their findings on the Decepticons to the Pentagon.
Sam and Mikaela soon meet Optimus Prime and his other Autobot partners Jazz, Ironhide, and Ratchet. They explain their origins to the two humans and insist on the urgency to get to the AllSpark first before the Decepticons, knowing that the Decepticons plan to use it to turn all of Earth's technologies into a new army of Decepticons and render humans extinct. The Autobots bring the two humans back to Sam's house to find the glasses, and they nearly reveal their existence to Sam's parents by accident. However, Sector 7 agent Seymour Simmons and his team find Sam and take his family away to a classified location after learning Sam came into contact with the Autobots. Optimus and the Autobots try to rescue Witwicky and Banes, however they fail and Bumblebee ends up getting captured along with Witwicky and Banes. The Autobots, however, retrieve the glasses and use them to find the AllSpark's location so they can destroy it before the Decepticons use it. Sam and Mikaela are taken to Hoover Dam, along with Maggie Madsen and Glen Whitmann, two hackers who were captured by the Federal Bureau of Investigation for trying to decipher the information Frenzy stole while working in the Pentagon.
Frenzy, who was transported to the dam while in disguise, finds the AllSpark and contacts the other Decepticons, Starscream, Bonecrusher, Brawl, Barricade, and Blackout. Starscream attacks the dam and Frenzy frees Megatron from his frozen prison, where he joins his cohorts into pursuing Sam and the Autobots. Bumblebee shrinks the cube to a reasonable size so they can escape with it. They then arrive at Mission City, where a large battle ensues. Working together, the Autobots and human soldiers defeat Bonecrusher, Blackout, and Brawl. However, Bumblebee is crippled, and Jazz is killed by Megatron. When Megatron begins to gain the upper hand in the fight, Optimus urges Sam to put the AllSpark in his chest, which will destroy them both. Instead, Witwicky inserts the cube into Megatron's chest, which kills him and destroys the AllSpark.
In the aftermath, the dead Transformer bodies are dumped into the Laurentian Abyss in the Atlantic Ocean to be hidden, the government orders the closure of Sector 7, and the Witwicky family is released from custody. Sam and Mikaela soon start a new relationship, and Optimus says that the Autobots' fates have given them a new home, Earth, and sends a message calling out all surviving Autobots to join them. In a mid-credits scene, Starscream escapes into space, processing the events of the second movie.