The film opens with Optimus Prime, heroic leader of the benevolent Autobots, describing in a voice-over the destruction of the Transformers' home world, Cybertron. It was destroyed by the evil Decepticon leader Megatron in his quest to obtain the All Spark. The Autobots want to find the All Spark so they can use it to rebuild Cybertron and end the war between the Autobots and the Decepticons, while the Decepticons want to use it to defeat the Autobots and conquer the universe. Megatron found the All Spark on Earth, but crash-landed in the Arctic Circle and was frozen in the ice. Captain Archibald Witwicky and his crew of explorers stumbled upon Megatron's body in 1897. Captain Witwicky accidentally activated Megatron's navigational system and his eye glasses were imprinted with the coordinates of the All Spark's location. Sector 7, a secret United States government organization founded by Herbert Hoover, discovered the All Spark 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 reverse engineered to advance human technology.
In the film's backstory, the Hoover Dam is built around the All Spark (which crash-landed in the Colorado River) to hide its energy signal from the Transformers.
In the present day, the rest of the Decepticons—Blackout, Scorponok, Frenzy, Barricade, Starscream, Devastator and Bonecrusher—have landed on Earth and assumed the disguise of Earth vehicles (except Scorponok, who hides within Blackout). Blackout and Scorponok attack the U.S. SOCCENT FWD military base in Qatar and try to hack into the U.S. military network to find the location of Megatron and the All Spark. Their mission is thwarted when the base staff severs the network cable connections. While Blackout destroys the rest of the base, Scorponok chases a small group of survivors who have photographic evidence of the robots, but he is eventually repelled. During this battle, the military discovers the only effective weapons against the Transformers' armor are high-heat sabot rounds.
After Blackout's failure, Frenzy infiltrates Air Force One to again hack into the military network, and plants a virus. He finds the map imprinted on Captain Witwicky's glasses, whose descendant Sam, intends to sell on eBay. Frenzy and Barricade begin tracking Sam's location. Autobot scout Bumblebee is also on Earth, disguised as a 1976 Chevrolet Camaro,[2] and is bought by Sam while shopping for his first car. Bumblebee helps him woo his crush, Mikaela Banes. Bumblebee leaves at night to transmit a homing signal to the rest of the Autobots and Sam sees him in robot mode. Barricade confronts Sam and demands Archibald's spectacles, but Bumblebee rescues him and Mikaela. They leave to rendezvous with the rest of the Autobots—Optimus Prime, Jazz, Ironhide, and Ratchet—who have landed on Earth and taken the forms of Earth vehicles as well. Sam, Mikaela, and the Autobots return to Sam's home and obtain the glasses; however, agents from Sector 7 arrive and capture Sam, Mikaela and Bumblebee.
Frenzy, disguised as Mikaela's cellphone, secretly accompanies the group to Hoover Dam and releases Megatron from his frozen state. Locating the All Spark, Frenzy sends an alert to the other Decepticons. Sam convinces the Sector 7 agents to release Bumblebee so that he can get the All Spark to Optimus Prime. Frenzy's virus has shut down government communications, but a group of humans manage to establish a signal to the Air Force in order to support the Autobot-human convoy, who have gone to Mission City (which is 22 miles away) to hide the All Spark. The Decepticons attack and Bonecrusher, Frenzy, Jazz, Devastator and Blackout are all killed during the ensuing battle. Sam, who is ordered to get the All Spark to a rendezvous point for it to be taken to a safe location, instead chooses to ram it into Megatron's chest, destroying the All Spark and killing Megatron. Optimus takes a fragment of the All Spark from Megatron's corpse, but realizes that with its destruction, their home world Cybertron cannot be restored. Consequently, Optimus sends a signal to other surviving Autobots in the universe, directing them to their new home, Earth. The government orders the closure of Sector 7 and has the five Decepticons killed in Mission City battle dumped into the Laurentian Abyss. Starscream, who fled the battle, escapes into space.