Plot
While searching the universe for planets for his master Galactus to consume, Silver Surfer is captured by Doctor Doom, and his board shattered into multiple "Cosmic Bricks". Having been warned about Galactus' upcoming arrival on Earth by an imprisoned Loki, Doom aims to build his "Doom Ray of Doom" using these bricks, which will allow the pair to defeat Galactus and then take over the world. Meanwhile, Nick Fury enlists Earth's heroes to retrieve the bricks before they fall into the wrong hands.
Sandman and Abomination, hired by Doom to retrieve a brick, hold Grand Central Station hostage for it, but are defeated by Iron Man, Hulk, and Spider-Man. The brick is left in the Fantastic Four's care at the Baxter Building, but Doctor Octopus steals it, forcing Mister Fantastic and Captain America to pursue him. Aided by Spider-Man when the fight goes through the Daily Bugle, they defeat him in Times Square, but he tosses the Brick to Green Goblin. Tasked with retrieving it, Black Widow, Hawkeye, and Spider-Man infiltrate Oscorp, but are forced to fight Venom while the Green Goblin escapes.
Iron Man and Hulk respond to a prison riot at the Raft, orchestrated by Magneto, Mystique, and Sabretooth to break out Loki and other villains. Aided by Wolverine, they defeat the escaped inmates and Sabretooth, but Magneto destroys Iron Man's armor and escapes with Mystique and Loki. Captain America and Iron Man go to Stark Tower so that the latter can retrieve his latest suit, only to encounter Loki, Mandarin, and Aldrich Killian, who have hacked J.A.R.V.I.S., turning it against the heroes. After restoring J.A.R.V.I.S. back to normal, they defeat the Mandarin and Killian, but Loki escapes with one of Stark's experimental Arc Reactors.
After S.H.I.E.L.D. tracks the reactor's signature to a Hydra base beneath the Empire State Building, Black Widow and Hawkeye investigate and discover that the Red Skull and Arnim Zola are building a portal generator powered by the stolen reactor, which Loki uses to travel to Asgard. Human Torch, Captain America, and Wolverine arrive to help defeat Red Skull, but inadvertently damage the portal generator. Pursuing Loki with Thor's help, the trio discover that he invaded Asgard, aided by the Frost Giants, and has stolen the Tesseract. Loki unleashes the Destroyer upon the heroes, but they defeat it and retrieve the Tesseract, despite Loki's escape.
Wolverine takes the Tesseract to the X-Mansion for Professor X to analyze it, but Doom dispatches the Brotherhood of Mutants to retrieve it. The X-Men defeat Toad, Pyro, and Juggernaut, but fail to prevent Magneto and Mystique from stealing the Tesseract. Tracking it down to Latveria, Nick Fury and the Fantastic Four storm Castle Doom, defeat Green Goblin, and rescue Silver Surfer, but Doom and Loki escape.
Iron Man, Thor, and Spider-Man later infiltrate a A.I.M. submarine where Doom is hiding out, defeating MODOK and capturing Doom with Jean Grey's help. However, Magneto magnetically controls the Statue of Liberty and uses it to rescue Doom. Despite Mister Fantastic, Wolverine, and Hulk's attempts to stop him after defeating Mastermind, Magneto brings the Statue to an island filled with dinosaurs from the Savage Land, whereupon he uses a nuclear core stolen from Roxxon Industries to power his space station, Asteroid M. Captain America, Storm, and Thing pursue Magneto and defeat Rhino and Mystique, but fail to prevent the station's launch.
Iron Man, Thor, and Spider-Man board Asteroid M and defeat Magneto, before confronting Doom and Loki, who have finished building the Doom Ray. After Doom incapacitates Iron Man and Thor, Captain America, the Thing, and Storm arrive to help Spider-Man defeat him. However, Loki reveals that he had manipulated Doom into building a flying pod, powered by the Tesseract, that will allow him to control Galactus and destroy Earth and Asgard. After Galactus arrives to consume Earth, Loki mind-controls him into destroying Asteroid M, though everyone aboard survives.
To stop Loki and Galactus, the heroes and villains form an uneasy alliance, and manage to open a portal to an unknown region of space and send the two through it, destroying Loki's pod and freeing Galactus from his control in the process. While Nick Fury recovers the Tesseract, the heroes decide to give the villains a head start to avoid capture. With his board rebuilt, Silver Surfer recovers his powers and leaves Earth, promising to lead Galactus far away.
In a mid-credits scene, Fury oversees the repair of the Statue of Liberty, when the Guardians of the Galaxy arrive, having been called earlier to help against Galactus, but they arrived too late. Star-Lord warns Fury that there is something else threatening Earth. Later while having lunch with the construction crew, Fury encounters Black Panther, who was looking for his cat Mr. Tiddles and tells Fury that the people of Wakanda are grateful to him.