Optimus Prime, leader of the benevolent Autobots, narrates the collapse of the Transformers' home world, Cybertron. It was destroyed by war between the Autobots and the malevolent Decepticons, lead by Megatron in his quest to get hold of the AllSpark. The Autobots want to find the AllSpark so they can use it to rebuild Cybertron and end the war, while the Decepticons want to use it to defeat the Autobots and take over the universe. Megatron had 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 eye glasses 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 arrives in a U.S. military base in Qatar to find the location of Megatron and the AllSpark. He tries to hack into the files of the computer base, but is stopped by Captain William Lennox and his team. 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. Then he meets Thomas the tank engine, Twilight Sparkle, and their friends. Later, they all catch 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 US Security Defense before he can retrieve all of the file information. Frenzy is then picked up by his partner Barricade and they go after Sam after learning he has the glasses needed to find the AllSpark. Sam and our heroes are rescued by Bumblebee and Mikaela also learns of the Transformers' existence. Bumblebee fights Barricade and manages to subdue him while Twilight uses her magic to decapitate Frenzy, but he still survives.
Meanwhile, Scorponok, who was sent by Blackout, goes after Captain Lennox and his team, murdering one of them and injuring another. During the battle, Scorponok is forced to retreat when he gets injured by sabot rounds dropped on him by the Air Force. Sam, Mikaela, and our heroes soon meet Optimus Prime and his other Autobot partners Jazz, Ironhide, and Ratchet. They explain their origins to the two humans, and 34 others 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 Transformers and render humanity extinct. The Autobots bring the two humans, and our heroes back to Sam's house to find the glasses, and they nearly reveal their existence to Sam's parents. However, Sector 7 agent Seymour Simmons and his team find Sam and take his family, the ponies, and Spike away to a classified location after learning Sam came into contact with the Autobots. However, Sam, Mikaela, the ponies, and Spike are rescued by Optimus and the Autobots, and the 22 engines, but Bumblebee ends up getting captured. The Autobots get the glasses and use them to find the AllSpark's location so they can destroy it so the Decepticons cannot get to it. Sam, Mikaela, our heroes along with two hackers named Maggie and Glenn arrive at Hoover Dam, where Maggie and Glenn got arrested by the FBI for trying to decipher the information Frenzy stole.
Frenzy finds the AllSpark and gets his body back, then 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 chasing down Sam, the Autobots, and our heroes where Bumblebee has shrunk the cube to a reasonable size. They then get to Downtown Los Angeles, where a large battle ensues. Working together, the Autobots and human soldiers kill Bonecrusher, Blackout and Brawl. However the war causes Bumblebee to get crippled, and Jazz is killed by Megatron. Optimus urges Sam, The Cutie Mark Crusaders (Apple Bloom, Sweetie Belle and Scootaloo), Peter Sam, Sir Handel, Duncan to put the AllSpark in his chest, which will destroy them both, but Sam, Apple Bloom, Sweetie Belle, and Scootaloo instead inserts the cube into Megatron's chest from Peter Sam's suggestion, which kills him and destroys the AllSpark. 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 are 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. With our heroes in the background watching them happily. In a mid-credits scene, Starscream escapes into space.
- Optimus Prime knows all the engines' and ponies' names.
- Both My Little Pony Friendship is Magic and Transformers was made by Hasbro.
- The storyline continues in Thomas and Twilight Sparkle's Adventures of Transformers Revenge of the Fallen.