The movie opens with Optimus Prime, an Autobot, narrating the history of the AllSpark, a cube-shaped artifact capable of granting independent life to normal electronic and mechanical objects, which is the source of life for all Transformers, both Autobots and the evil Decepticons.
Their society flourished until they were betrayed by Megatron; and war erupted over the AllSpark, which was lost and ended up on an unknown planet, Earth.
Fast forward thousands of years to present day Earth, Qatar, to be exact, where American soldiers are stationed. They fly in to their base and go about the usual routine. Capt William Lennox [Josh Duhamel] is contacting his wife and seeing his baby girl again, when a helicopter previously thought to have been shot down over Afghanistan comes up on the radar. It lands at the base, and the base commander orders it to stand down; but, instead, it transforms into the Decepticon Blackout and attacks the base. Blackout also lets out some kind of jamming field that blocks all communication channels. He blasts his way through the base, only momentarily dazzled by flares shot at his face (which saves Tech Sgt Robert Epps [Tyrese Gibson], after Epps got scans of Blackout). Blackout locates the base's mainframe and downloads information until the humans cut the computer's hardline, terminating the network's connection. Blackout then destroys the base and everyone on it, save for a few who escape. Blackout then releases Scorponok into the sand to hunt down the survivors.
Back in America, we see Sam Witwicky [Shia LeBeouf] supposedly giving a report in front of his class but is, instead, hawking his grandfather's memorabilia for eBay sales. His grandfather, Archibald Witwicky, was a famous 19th century explorer who tried to reach the Arctic circle. He later went crazy after claiming to have found a giant man frozen in the Arctic ice. Sam's teacher is none too pleased at Sam's antics, but Sam manages to talk him into giving him an A, so that he can take his money and his A to his father, Ron Witwicky [Kevin Dunn], to buy a car.
Initially, Sam's father teases him by driving into a Porche dealership; but, when the joke's over, he takes Sam to Bolivia's Used Car Sales, where Bobby Bolivia [Bernie Mac] tries to sell Sam a car. As they drive up, though, an unmanned yellow Camaro drives up and parks itself in the lot. Sam is none too pleased with his choices until he sees the Camaro. It seems to be the best thing there. He and his dad just have $4,000 to spend; but Bobby asks for $5,000, even though he admits that he doesn't know what the car is doing on his lot. Ron tries to talk him down to 4 grand, but Bobby balks at that, and instead offers a Yellow VW Beetle for $4,000. The Camaro's passenger door randomly swings open and crunches in the side of the beetle, so Bobby quickly tries to show them another car. A strange sonic pulse emanates from the Camaro, blowing out every windshield in the lot (save its own); and Bobby Bolivia quickly delivers up the Camaro for $4,000.
In the Pentagon, Defense Secretary John Keller [John Voight] addresses up a team of computer analysts and scientists to try to determine who attacked the base in Qatar. They've received no word from survivors, and all they have to go on is the sound of the signal used to tap in and download sensitive information from the U.S. Government's computer networks. Maggie Madsen [Rachael Taylor] heads one of their teams.
Sam takes his car out for a spin and they run across Sam's crush, Mikaela Banes [Megan Fox], and the jock boys she hangs out with. First, the jocks try to intimidate Sam; but Sam's witty comebacks regarding brain damage from playing football overcomes their male posturing. As Sam is ready to leave, Mikaela angrily leaves the jocks to walk home, so Sam kicks his friend out of the car and offers her a ride. She accepts, after Sam finishes his fumbling invitation. Everything seems cool until the car mysteriously stops working near a local make-out spot. The Camaro also mysteriously cuts on the radio to play "Let's Get It On", much to Sam's shock. Mikaela, who is surprisingly car-savvy, takes a look under the hood and is impressed by the engine but can't seem to see any problem past the distributor cap being loose. She decides to go ahead and finish the walk home. Sam begs for the car to start as she leaves. The car suddenly starts and begins blasting "Baby Come Back". Sam spins the car around and gives Mikaela a ride home.
In Qatar, a local boy leads the surviving soldiers to his village, where they will be able to use a phone. The have no idea that they are being followed beneath the sand. Out of nowhere Scorponok attacks and begins killing the soldiers. Lennox manages to get a cellular phone but needs a credit card to activate it, which he gets from Epps, as Epps tries to keep the Decepticon at bay. After dealing with an annoyingly humorous Arab operator, Lennox gets through to the military and gets an air strike ordered onto the village. They mark Scorponok with lasers and the A-10 Warthogs (reminiscent of Powerglide) bomb the hell out of the Decepticon. Scorponok flees beneath the sand after losing his tail. (They also later had helicopters that were the same model as Blades).
The Pentagon tries to alert the president, who is aboard Air Force One; but the aircraft has already been infiltrated. Frenzy hides beneath a passenger's seat, disguised as a boom box. He transforms and makes his way down to the plane's interior, where he finds the computer network. He accesses the mainframe and begins a massive download, focusing on facts about Archibald Witwicky and a secret government branch called "Sector 7" and their top secret "Project Iceman".
Maggie detects the intrusion and alerts the Pentagon, convincing them to take the whole network offline to stop the download. The Pentagon is frantic to discover who is behind all of this, as they suspect that it could be Russia, North Korea, or China. Maggie is warned to keep her imaginative ideas to herself, so she make a copy of the strange signal and leaves for a friend's house. When Air Force One lands, Frenzy escapes after killing several secret service agents and hops into a waiting police car (which has a Decepticon sigil on its fender). Frenzy remarks to the car, "The stupid insects tried to shoot me".
Later, Sam wakes to the sound of his car starting up. Fearing that it is being stolen, he pursues the car to a local junkyard and sees his Camaro transform into a giant robot. The "robot", an Autobot named Bumblebee assigned to protect Sam, sends a signal (in the shape of an Autobot sigil) into space. The police arrive and do not believe Sam's story. Thinking he's probably on drugs, they arrest him.
Maggie takes the top secret file to her friend Glen Whitman [Anthony Anderson], "the only hacker in the world" who could break the code. He cracks the signal just before Federal agents bust in and arrest them both.
Later after Sam's father bails him out, Sam sees that his car has returned. Terrified, he flees on his mother's pink bicycle and is pursued by Bumblebee. He rides fast until he crashes in right front of Mikaela. He quickly takes off again, and she follows him. Sam tries to hide from Bumblebee and is relieved when a police car rolls up. Sam explains his situation, presumably to an officer behind the wheel; but no officer appears and the black-and-white attacks him, suddenly sprouting bladed weapons from the headlights and the grill. The car transforms into Decepticon Barricade and asks Sam if he is "Ladiesman217" (Sam's eBay ID), and Sam tries to escape again. Sam runs into Mikaela and tells her to run, because a monster is after him. Then she sees Barricade, too. Bumblebee drives up, the two reluctantly hop in, and the car chase begins.
Bumblebee leads Barricade on a wild chase and gets the teens away from the Decepticon so that he can face off with Barricade. Barricade battles Bumblebee but not before releasing Frenzy, who pursues the humans. Bumblebee and Barricade duke it out while Mikaela and Sam try to fend off the resourceful Frenzy. Eventually, Mikaela uses a saws-all to cut off Frenzy's head, which flees in Waspinator fashion just as Bumblebee leaves Barricade in a broken heap. Bumblebee beckons for the humans to come with him and reveals, through radio transmissions and songs, that he's an alien and that he has sent a signal asking for help from his comrades. Unknownst to them all, Frenzy's head has scanned Mikaela's cell phone and has transformed into it, hiding in her purse.
As they drive down the street, Mikaela asks, "So, if he's supposed to be like this super-advanced robot, why does he transform back into this piece-of-crap Camaro?,". Bumblebee slams on his brakes and pushes the kids out. Sam remarks, "See, now you've upset him", as Bumblebee speeds away. Suddenly Bumblebee spins around and gets up on two wheels, and his undercarriage scans a passing car. Bumblebee shifts and changes into a new-model Camaro, to Sam and Mikaela's amazement. They hop into Bumblebee and race away.
The Feds interrogate Maggie and Glen, who reveal that the signal pointed Project Iceman and the Witwickies. Soon afterward, Defense Secretary Keller calls them in for continued help. Elsewhere, Epps and Lennox study Scorponok's tail and discover that high-temperature 105 Sabot rounds can hurt the robots.
Next, several "meteors" fall from the sky. Autobots come out of the stasis pods and scan for vehicular forms. Most notably, Ironhide lands in a swimming pool; and a little girl who sees him asks if he's the tooth fairy.
Bumblebee leads the two humans to the Autobots' meeting place, where they are introduced to Optimus Prime, Ratchet, Jazz, and Ironhide. Optimus Prime tells them about the AllSpark and how Megatron searched the Galaxy for it and was lost. He explained how Sam's grandfather discovered Megatron frozen in the ice and accidentally activated Megatron's navigational system, which imprinted Cybertronian script onto his eyeglasses. That script revealed the secret location of the AllSpark, and its recovery was of the gravest importance, because the Decepticons would use it to give life to Earth's machines, creating a new army of Decepticons, and causing humanity to go extinct.
Sam leads them back to his home where the Autobots accidentally trample his yard and demolish the lawn decorations. Sam finally finds the glasses with his mother's help (after his mother has an embarrassing discussion in front of Mikaela concerning Sam's masturbation habits). Sam gets the glasses to Optimus Prime just before Sector 7 swoops in and arrests Sam and Mikaela. The Sector 7 operatives try to coerce info about the aliens from Sam and Mikaela, until Optimus Prime opens the agents' car like a tuna can and forces them to release the kids. The Autobots surround them and allow the kids to handcuff the agents all together, after Bumblebee pops off what looks like his oil filter and essentially urinates lubricant on Agent Simmons. Optimus notes that Simmons is neither afraid nor surprised to see the Autobots.
The agents secretly alert the military, who try to track down Optimus Prime and the kids, while the other Autobots split up. Bumblebee is discovered trying to save the kids after they fall off of the hidden Optimus, and is captured by the government, along with Sam and Mikaela. Sam, Mikaela, Maggie, Glen and the captive Bumblebee are all taken by Sector 7 and Keller to Sector 7's secret base, deep within Hoover Dam, where they are shown "Project Iceman", the frozen form of Megatron. Sam tries to warn them about Megatron and catches their attention when he mentions the cube-shaped AllSpark.
It turns out that all modern technology was reverse-engineered from Megatron's body and that the AllSpark could give that technology life, though it usually proved to be violent and destructive to organics. They demonstrate by infusing Glenn's cell phone with the Allspark's energy, and the phone transforms into a tiny robot who viciously attacks the humans. Frenzy sneaks out of Mikaela's purse and touches the AllSpark, regenerating his body; and he sends out a signal, telling the other Decepticons that the AllSpark has been found. Around the world different Decepticons respond: StarScream, Barricade, BoneCrusher, Blackout and Devastator all converge on Hoover Dam. Elsewhere the Autobots decipher the Allpark's location and also head to the Dam. Optimus states that, if they cannot win, he will sacrifice himself by absorbing the AllSpark into his own Spark, destroying the artifact and himself as well.
Frenzy sabotages the cryo controls that keep Megatron frozen, and the Decepticon leader begins to wake up. Sam convinces Keller, with some help from Lennox, that Bumblebee is no threat and will in fact help them against Megatron. Bumblebee is reactivated and he transforms the AllSpark into a more portable form. They then proceed to escape from the Dam and make their stand in a nearby town. Megatron breaks free and is greeted by StarScream, who reports that the Autobots have fled with the AllSpark. Megatron remarks, "You have failed me, yet again, Starscream".
As Megatron and Starscream went to assist the rest of the Decepticons in securing the All Spark, Frenzy remained at the dam to tie up any loose ends. When Agent Simmons, Secretary Keller, Maggie and Glen Whitmann ran to an ancient storage room to try and get a Morse Code message to the Air Force via shortwave radio, Frenzy followed. While Glen jury-rigged outdated machinery to send the messages, Simmons and Keller tried to shoot the diminutive Decepticon. Frenzy made it into the room via the air ducts and sent a series of flying blades at the humans. One, however, he ricocheted madly across the room, and is soon decapitated. With a muttered "oh sh*t," Frenzy collapsed, dead.
Around the same time, the Autobots encounter Bonecrusher on the highway, flanked by Barricade, and Optimus takes Bonecrusher on. The two are carried over a high overpass and battle ensues below. Bonecrusher seems to be a powerful warrior, but Optimus proves to be his better and kills the Decepticon with a long sword blade from his arm.
The Military and the Autobots try to set up defenses in the town, but that is soon disrupted by Megatron's arrival. Devastator and Blackout lay waste to different parts of the town, as they battle Ironhide and Ratchet. Starscream soon wounds Bumblebee, having both his legs destroyed, as well.
Lennox calls in air support, but most of the jets are shot down by Starscream. Lennox then orders Sam to take the Allspark and take it to the highest building and use a signal flare to attract and escape upon evac helicopters. The Autobots try to run defense to protect Sam. Jazz takes on Megatron and is quickly killed by being ripped in two. Along the way, Sam accidentally releases a burst to the AllSpark's energy, which gives life to many nearby machines, including a car and a Mountain Dew machine, which then attack any humans within reach.
Finally, Optimus Prime shows up declaring to Megatron that "one shall stand, one shall fall", and the two behemoths battle. Megatron overcomes Optimus and continues pursuing Sam. Atop the building Sam almost makes it to the helicopter, but it is destroyed before he can give them the cube. Megatron offers Sam the opportunity to survive as his pet if he would hand over the AllSpark. Sam refuses and Megatron attacks, causing Sam to fall off of the building. Optimus catches Sam, saving the boy and the AllSpark.
On the ground he and Megatron square off again. Elsewhere Mikaela chains the legless Bumblebee to a tow truck and pulls him through the battle field, allowing the Autobot for shoot while she drives. They, with the help of Ratchet, Ironhide, Lennox and Epps, take out Devastator and Blackout.
The battle reaches its climax, and Optimus asks Sam to release the AllSpark into his chest, but Sam releases it into Megatron's chest, killing the Decepticon leader. Optimus stands over Megatron, looking into his fading optics and laments for his "brother".
In the aftermath, Bumblebee regains his ability to speak and asks that he might remain with Sam. Sector 7 is dismantled and all of the Decepticon bodies are dumped into the sea, where the cold and pressure should keep them from ever being retrieved.
Optimus Prime laments that the AllSpark was destroyed, dashing any hopes of revitalizing Cybertron, so he instead broadcasts an invitation to any Autobots left to come make Earth their new home.
Then the credits roll.
During the credits it flashes back to a scene of Starscream flying up and out of Earth's atmosphere and rocketing into space...