The Tesseract, the cosmic cube that Red Skull sought and that S.H.I.E.L.D. has studied for decades, activates on its own. A portal opens in the research facility, and through it steps Loki, the Asgardian god of mischief, very much alive and wielding a scepter of terrible power. He kills several agents and uses the scepter to take control of Dr. Erik Selvig and Agent Clint Barton, also known as Hawkeye. Loki escapes with the Tesseract, intending to use it to open a portal for an alien army to conquer Earth.
Nick Fury activates the Avengers Initiative. Agent Natasha Romanoff, the Black Widow, recruits Bruce Banner from hiding in Calcutta—S.H.I.E.L.D. needs his expertise in gamma radiation to track the Tesseract. Agent Phil Coulson approaches Tony Stark, who reluctantly agrees to consult. Fury himself briefs Steve Rogers, recently thawed and struggling to adapt to the 21st century.
The team assembles on the Helicarrier, S.H.I.E.L.D.'s flying aircraft carrier. The personalities clash immediately. Tony and Steve take an instant dislike to each other: Steve sees Tony as a selfish showboat, while Tony resents being compared unfavorably to Howard Stark, whom Steve knew personally. Banner is nervous, treated like a bomb that might go off. Romanoff is cool and professional, hiding deep trauma.
Loki allows himself to be captured in Stuttgart, Germany, where he demands a crowd kneel before him. Steve confronts him, joined by Tony in the Iron Man suit. On the way back to the Helicarrier, Thor arrives to take his brother back to Asgard. A three-way battle between Thor, Iron Man, and Captain America ends in a tense standoff before they agree to work together.
On the Helicarrier, Loki is imprisoned but unnervingly calm—because getting captured was his plan. The scepter subtly influences the team, amplifying their conflicts. Meanwhile, the controlled Hawkeye leads a strike team to attack the Helicarrier, disable one of its engines, and free Loki. During the chaos, Romanoff is trapped with a transforming Banner, nearly killed when he becomes the Hulk. Thor tries to contain the Hulk but is ultimately trapped in Loki's cell and ejected from the carrier.
The attack's true cost becomes clear when Loki kills Agent Coulson, stabbing him through the heart with the scepter. Coulson's death, and his belief in the idea of the Avengers, becomes the catalyst that unites the fractured team. Fury uses Coulson's trading cards, stained with blood, to drive the point home.
Tony figures out Loki's plan: he's going to use Stark Tower's arc reactor to power a device that will open a stable portal for the alien Chitauri army. The team races to New York City, but they're too late to stop the portal from opening. The Battle of New York begins.
The Avengers fight together for the first time, each playing to their strengths. Captain America coordinates from the ground, directing police and keeping civilians safe. Thor uses lightning to bottleneck the portal. Hawkeye provides overwatch, taking impossible shots. Black Widow fights her way to the portal device, where Selvig—briefly freed from Loki's control—reveals that the scepter can close it.
Tony discovers the Chitauri are controlled by a mothership; destroy it, and the army falls. When the World Security Council launches a nuclear missile at Manhattan, Tony intercepts it and carries it through the portal himself, aiming for the mothership. The bomb destroys the Chitauri command ship, killing all the invaders instantly—but the portal is closing, and Tony is on the wrong side.
At the last possible moment, Tony falls back through as Romanoff closes the portal. He's not breathing. The Hulk roars, shocking Tony back to consciousness. The team stands victorious, exhausted, and finally united.
In the aftermath, Thor takes Loki and the Tesseract back to Asgard. The others go their separate ways, but they've formed bonds that will last. Fury tells the World Security Council that the Avengers will return when needed. "Because we'll need them to," he says.
In a mid-credits scene, the alien leader who provided Loki with his army reports to his master: to challenge Earth is "to court death." The master turns and smiles—revealing the purple face of Thanos.
In a post-credits scene, the exhausted Avengers sit in silence in a destroyed shawarma restaurant, too tired to speak. It's perfect.