A medieval battle rages. King Arthur and his knights are looking down the barrel of defeat at the hands of the Saxons, and their only hope lies with the magician Merlin. Elsewhere Merlin, in reality merely a drunkard, rides up to a long-crashed alien ship and beseeches the occupants for help. He has kept their secret, but now needs their help. The other knights are losing hope, but Arthur believes Merlin will come through. Merlin manages to convince a giant metal knight at the ship to help, and it presents him with a staff, allowing him to return to the battle with a giant metal dragon. The battle is won in favor of Camelot.
Present day: Optimus Prime drifts apparently lifeless in space. Both he and Megatron have vanished from Earth, and Transformers have been declared illegal, with the Transformers Reaction Force set up to track them down, though they've found refuge in some places such as Cuba, where Seymour Simmons is hanging out with the remaining Wreckers. Transformers continue to arrive in waves and NASA scientists detect something large incoming.
Four kids, craving adventure, breach a fence and enter a section of city ruined by a previous Transformer battle. They stumble on a crashed Transformer ship with a still-living occupant. TRF Sentinels close in on them and warn them that they're trespassing; however Izabella appears out of nowhere to help, slinging bottles of green ooze which result in one Sentinels shooting another. Izabella's tiny robot Sqweeks wraps a cable around the legs of the remaining Sentinel and it topples over, allowing the kids time to get away. Pursued by another Sentinel, Izabella takes the kids to shelter — a Transformer named Canopy whose back is a hollow mound of rubble. They're joined by Sqweeks, who's lost his arm in the battle. Canopy and the kids start moving, unaware the TRF has spotted them. Unable to determine what faction Canopy is and with kids possibly in danger, TRF commander Santos orders an air strike. The missile takes out Canopy, who thanks a tearful Izabella before dying. The kids are soon rescued by Cade Yeager and Bumblebee who destroy another Sentinel.
Cade drives the kids to the border of the no-go zone and drops them off before returning to the crashed ship. Despite his efforts, the pilot within dies, but not before attempting to present Cade with the Talisman. Cade does not take it. He reports the pilot's death to Bumblebee shortly before Barricade appears and Cade is suddenly surrounded by TRF forces. Meanwhile, the Talisman sprouts legs and crawls away from the ship. Cade refuses to divulge where the other Transformers are. Bumblebee arrives, only to be blown to pieces by the TRF. Moments later, the parts start reconnecting as Bumblebee reassembles himself, sending the TRF forces into disarray as he does so. He and Cade take Santos hostage, but the standoff is interrupted by the arrival of Lennox who tries to talk Cade and Bee into standing down. Hound's appearance settles things however, and Cade, Bee and Hound leave, though the TRF manages to get a tracking device onto Bumblebee.
Lennox reports to General Morshower who plays a recording of Barricade reporting back to Megatron. Megatron is disappointed Barricade failed to secure the Talisman as it is the object they need to lead them to the staff, but Barricade believes the TRF will lead them to it. Morshower orders Lennox to return to his covert infiltration of the TRF.
Optimus's voyage through space comes to an end as he crashes on the ravaged surface of Cybertron, which has been mysteriously disassembled into many pieces. He encounters and attacks Quintessa, who claims to be his creator and the "Prime of Life," but she easily restrains him.
As he returns to the junkyard he calls home, Cade realizes that the Talisman has somehow ended up in his vehicle. In England, Cogman alerts Sir Edmund Burton to the arrival of the Talisman. Elsewhere in England, Viviane Wembly wins a game of polo for her team before returning to the University of Oxford. She lectures her class on King Arthur, someone she believes to be a made-up legend, unaware she's being watched by Burton. Burton gives instructions to a nearby parked car.
Quintessa tells Optimus that he must retrieve her staff, stolen by her knight guardians and hidden on Earth.
Drift and Crosshairs are hanging out in the junkyard. Cade, Hound, and Bumblebee stop off on their way back so Cade can banter with the local authority, Chief Sherman, who complains that his cruiser has been stolen. The trio continue to the junkyard where Jimmy and Wheelie are looking at online photos of custom cars. They are unaware Izabella and Sqweeks have stowed away on Hound. While Bumblebee and Crosshairs come to blows, Cade persuades Grimlock to cough up Sherman's cruiser, or what's left of it. Daytrader arrives, bringing Starscream's head and a new voicebox for Bumblebee. He's interested in Cade's Talisman, and says it's a sign of the impending apocalypse. Izabella fronts up to Cade and attempts to pursuade him to let her stay. They return to Cade's trailer for antics with the Mini Dinobots and trade stories of lost family members. Izabella manages to impress Cade with her knowledge of Cybertronian physiology and he's convinced to let her stay.
In Namibia, scientists arrive at a location to find a giant metal horn poking out of the ground. News of the horn, and five more like it, get back to Simmons and Burton. Meanwhile the NASA scientists meet with presidential staff to report they have detected an approaching planet, which they say will arrive in three days.
Helped by Hound, Cade makes an untraceable satellite phone call to his daughter at college, but is unable to speak to her for fear that his voice will be recognized by the CIA, and can only listen as she tries to convince him to get a girlfriend.
Lennox meets Morshower at the Pentagon for a briefing on the horns — Megatron has been spotted visiting them and has snatched up two CIA operatives as hostages. Lennox and some lawyers meet with Megatron to negotiate the return of some of his men. They agree to release Mohawk, Dreadbot, and Nitro Zeus; Berserker, however, turns out to be a step too far, and Megatron is forced to select Onslaught instead. Morshower believes they can use Megatron so they can get hold of Cade's Talisman themselves.
As morning breaks over the junkyard, the Decepticons prepare to move in, observed by the TRF. Izabella attaches a new arm to Sqweeks, before helping Cade fit Bumblebee's new voicebox. Bee is not happy with the result, which sounds like a GPS. Sherman gives the group advanced warning of the impending Decepticon assault, and the Autobots and humans scramble to get ready to escape. Megatron's group arrives to find the junkyard deserted, at least until Hound pops up and starts shooting. Megatron returns fire. The Autobot group heads into the nearby town, where Drift finds the tracking device on Bee. Grimlock and Slug ambush the TRF forces en route to the town. Santos has a swarm of unmanned drones sent in. The Decepticons arrive in the middle of town and immediately spot Sqweeks, which draws Izabella out in an attempt to save the tiny Autobot. Cade detonates the explosives hidden around town and flees with Izabella, pursued by Barricade. The 'Con is taken out by Grimlock, and as the battle rapidly turns against the Decepticons, Megatron calls a retreat. Cade, Izabella, and Jimmy take cover in a disused church as the TRF drones move in, however the drones continue to pursue them through the church. Cade and Izabella take two of them out, but Jimmy tries to bluff a third, banking on the idea it's using facial recognition. He gets shot anyway, but fortunately it was only a beanbag.
The trio head into another disused building and enter a lift where they encounter Cogman, who announces he's come to collect Cade. The discussion ends when a drone arrives, and Cade ends up clinging to it as it flies wildly around the street. Cogman phones Sir Burton to report the bad news, but fortunately Cade survives his impromptu flight, partly thanks to the Talisman protecting him from bullets. He manages to ride another drone to the ground and is met by Cogman who explains that he's important because of the Talisman. Crosshairs attempts to prevent Cogman from doing anything, only for the smaller robot to break his finger. Cogman convinces Cade to go with him and leave the others. Cade and Bee accompany Cogman on a plane to England.
Morshower and Lennox track the flight, and note that Megatron's group is giving pursuit. Lennox is ordered to take the TRF team to the UK as well.
Simmons calls Sir Burton to let him know a book has been tracked down. NASA continues tracking the incoming planet, now identified as Cybertron. Quintessa reveals to Optimus that Earth is actually Unicron and that they're going to kill him with the staff, an act which will destroy Earth and restore Cybertron. Optimus's optics turn purple as Quintessa addresses him as "Nemesis Prime". Optimus swears to fight anyone who interferes with his new mission.
Viviane and her family watch a news report on the giant horns. Conversation turns to her dead father, and her mother suggests she check her father's study in case there's anything useful for her work. Disinterested, she instead gets into her car where an invitation falls out of the glove compartment. The car takes off of its own accord and starts driving her through the streets of London. When she smashes a window, the car complains in a French accent and throws her into the trunk. She calls for help, having realized she's in a Transformer, and the car scans a passing Lamborghini, reconfiguring itself into a copy of the other vehicle.
Cade's plane lands at Sir Burton's castle, where he and Bumblebee are shot at by a tank Transformer. Sir Burton apologizes and takes a look at the Talisman. Hot Rod arrives carrying Viviane, who is unhappy at being kidnapped. Once things calm down, Sir Burton explains he's the last of the Order of the Witwiccans. Cade's boorish behavior towards Viviane results in him being assaulted by Cogman. Sir Burton shows off portraits of his family tree and the Witwiccans, and relates how the Transformers have been helping humans for centuries, such as when Bumblebee and Hot Rod took part in World War II. They head to another building which houses the original Round Table used by King Arthur and his knights when they teamed up with the twelve Knights of Iacon. Further there is a legend that a last knight would be found and thanks to possessing the Talisman, that's Cade. Only Merlin's DNA can unlock the power of the staff, which is where Viviane comes in as a direct descendant of Merlin. She has no idea where the staff might be though. Further discussion is halted as MI6 and TRF forces arrive to assault the castle. Hot Rod's time stopper weapon gives the group enough time to escape.
Simmons makes an irate call to Sir Burton, who is currently being pursued through London and is late for the appointment at Trinity Library. Bumblebee arrives at Viviane's house with her and Cade, and the pair start rifling through her father's study in search of a clue. Sir Burton's dropped off at the library, but Simmons demands to be inducted into the Order of Witwiccans before he'll point Sir Burton to the book, which reveals Earth is Unicron and points them to Stonehenge. Cade and Viviane find a clue in an old popup book which points them to the HMS Alliance at the navy museum. The TRF arrive at the house. Meanwhile, Sir Burton and Cogman switch cars and a high-speed chase through the streets of London ensues. Cade and Viviane, now also making a getaway in Bumblebee, let them know about the navy museum. Cogman manages to shake his pursuers while Bumblebee manages to shake Barricade by blasting the Decepticon.
Bumblebee reaches the naval museum at the same time as Cogman and Sir Burton, and they have the HMS Alliance evacuated. Sir Burton leaves the others to it, explaining that the submarine, in reality a Transformer, knows the way to the staff. The sub launches, with Bumblebee clinging to the exterior so he cam come along for the ride. The sub's departure is noted by TRF and they track it as it heads away from England. The TRF scramble their own submersibles to give chase. A nuclear sub fires missiles at the Alliance which responds by ramming the other sub and diving deeper into the ocean. Cogman fires himself out through a torpedo tube.
Sir Burton arrives at Number 10 to see the Prime Minister, but is turned away. Cogman returns to the sub with a couple of fish he's caught. Viviane and Cade share clumsy sexual chemistry until Cogman reveals he's made sushi as a "last meal". Sir Burton takes a secret back entrance into Number 10 to talk to the PM, holding off security by threatening to release the watch that killed Hitler. Sir Burton tells the PM to mobilize the military to Stonehenge. The Alliance zeros in on a vast undersea Transformer ship, which lights up as they approach. The pursuing TRF subs also spot the ship, but have to make their own way in after the airlock doors close behind the Alliance. The Alliance surfaces beyond the airlock, and the group starts exploring.
Back at the junkyard, Izabella, Sqweeks, and Crosshairs look up at the approaching Cybertron. Elsewhere, NASA scientists give a briefing as the approaching planet scrapes the surface of the Moon. The doomsday news is broadcast on television around the world. The subs carrying the TRF teams led by Lennox and Santos emerge into an air pocket, and they move out. Daytrader arrives back at the junkyard with the Autobots' ship, and the group there prepares to head to England to help out. Cade and Viviane find a chamber holding motionless Knights of Iacon. Cybertron moves into Earth's atmosphere, passing the International Space Station. Viviane touches a Celtic engraving which reveals Merlin's sarcophagus, inside which they find a wooden staff. As the TRF moves through the same chamber, one of the knights springs to life. Cade keeps it distracted as the TRF attacks it, eventually bringing it down. Viviane grabs the wooden staff which transforms into metal in her hands. Lennox and Santos attempt to get her to hand it over, but she reveals only she can use it. More knights revive and attack, however a short time later, Optimus kills them and forces Viviane to turn the staff over to him. Sending the others back to the sub, Cade, Lennox, and Bumblebee go after Optimus.
Bumblebee fights with Optimus atop the vast ship as it comes to the surface. Bumblebee manages to get the better of his former leader, and Cade attempt to persuade Optimus to stop fighting. As the ship rises out of the water, Optimus is able to get the upper hand and is prepared to end Bumblebee when Bee manages to talk in his own voice. Shaking Quintessa's influence, Optimus drops his sword, just in time for Megatron to swoop in and claim the staff. After the Decepticons leave, the remaining Knights of Iacon emerge from the ship and are ready to execute Optimus for aiding Quintessa's cause. The Talisman transforms into a sword which Cade uses to block the killing strike, and the Knights recognize Cade as a knight. Though Prime is ready to die, Cade talks him out of sacrificing himself, and Optimus announces they have to destroy Quintessa. Also the other Autobots show up in their ship.
Cybertron makes touchdown on Earth, causing untold destruction. Megatron arrives at Stonehenge with the staff. Lennox contacts Morshower with the coordinates for the "end game", an ignition chamber which is part of one of the dangling pieces of Cybertron and military forces move in. Cade comes up with a plan to load Ospreys onto the Autobot ship so they can get close enough to the ignition chamber to land. NASA thinks this is a bad plan and works on an alternate idea. The massive ship continues towards Stonehenge where the Decepticons, along with Sir Burton and the military forces, are waiting. At Sir Burton's signal, the military opens fire on the Decepticons as the massive ship arrives directly overhead. Megatron blasts Sir Burton. The Autobots regroup with Cade and the TRF and Optimus Prime gives a stirring speech before blasting off. Cogman manages to find Sir Burton shortly before he expires.
Megatron returns to the Ignition Chamber where Quintessa is waiting. She plugs the staff into the floor, and lightning starts arcing about. The pieces of Cybertron start moving about and joining together, causing those on the ground to run for their lives. Massive worldwide destruction ensues. As the Autobot ship carries Autobots, knights and humans up to their fates, Cade asks Viviane out on a date. Jets soften up the defenses around the ignition chamber while the humans all board the Ospreys, and Cade has it out with Santos. Shamed, the TRF troops all rip off their insignias. The Ospreys launch, and Izabella and Sqweeks reveal they've stowed away on the one carrying Cade and Viviane. Covered by the jets and the giant three-headed dragon, the Ospreys head to the ignition chamber, and crash-land on the surface. The landing site is immediately a war zone as Megatron and his Decepticons stand in their way. Lennox spots the entrance to the chamber, but the team is pinned down by a gun emplacement. Izabella instructs Sqweeks to go blow the gun emplacement up. Infernocus merges and knocks Bumblebee and co out of the air.
Meanwhile the NASA scientists have come up with a plan to use nukes to cause a nearby chunk of Cybertron to destroy the ignition chamber. Morshower contacts Lennox to let him know the new plan, and the TRF forces start withdrawing. Sqweeks succeeds in blowing up the gun emplacement. Optimus arrives aboard the dragon and takes out Infernocus. As the TRF troops parachute off the platform, the jets nuke the neighbouring chunk of Cybertron. Viviane drops her parachute and heads back towards the chamber, followed by Cade. The chunk hits the platform containing the chamber, however despite the devastating impact, the chamber continues to function. The chamber tumbles down until it comes to rest on another part of Cybertron. Inside, chaos reigns as the Autobots and Decepticons fight and Viviane grabs the staff. Optimus kicks Megatron through a wall shortly before another impact sends the chamber tumbling out of the sky. Optimus and Bumblebee manage to defeat Quintessa, the latter blasting her. Quintessa vanishes in a flash of blue light. Viviane finally pulls the staff free, shutting down the Ignition Chamber just before it crashes to the ground. Optimus dramatically drives out of the cloud of debris raised by its impact, carrying Cade and Viviane. As everyone reunites, Optimus gives another stirring speech about how Earth and Cybertron are now joined as one.
Meanwhile, back in Namibia, Quintessa, now in a human form, walks up to one of the scientists studying the giant metal horn and offers to tell him how to kill Unicron.
- Mark Wahlberg as Cade Yeager
- Anthony Hopkins as Sir Edmund Burton
- Josh Duhamel as William Lennox
- Laura Haddock as Vivian Wembly
- Isabela Moner as Izabella
- Stanley Tucci as Merlin
- John Turturro as Seymour Simmons
- Jerrod Carmichael as Jimmy
- Santiago Cabrera as Santos
- Gleen Morshower as General Morshower
- Liam Garrigan as King Arthur
- Mitch Pileggi as a TRF Group Leader
- Optimus Prime (voiced by Peter Cullen)
- Bumblebee (voiced by Erik Aadahl)
- Crosshairs (voiced by John DiMaggio)
- Drift (voiced by Ken Watanabe)
- Hound (voiced by John Goodman)
- Hot Rod (voiced by Omar Sy)
- Canopy (voiced by Frank Welker)
- Sqweeks (voiced by Reno Wilson)
- Cogman (voiced by Jim Carter)
- Ironhide (picture only)
- Topspin (voiced by Steven Barr)
- Megatron (voiced by Frank Welker)
- Barricade (voiced by Jess Harnell)
- Onslaught (voiced by John DiMaggio)
- Mohawk (voiced by Reno Wilson)
- Nitro Zeus (voiced by John DiMaggio and Steven Barr)
- Starscream's head
- Quintessa (voiced by Gemma Chan), a Cybertronian sorceress and the creator of Cybertronians, who wants to destroy "Unicron" and revive Cybertron.
- Infernocons, Quintessa's demon-like guardians who combine to form Infernocus.