Nick Fury (Samuel L. Jackson), director of S.H.I.E.L.D. (Strategic Homeland Intervention, Enforcement, and Logistics Division), arrives at S.H.I.E.L.D. headquarters outside of Santa Fe, New Mexico, during an evacuation. The Tesseract, an energy source of unknown potential, has activated. It opens a portal through space and the exiled Norse god Loki (Tom Hiddleston) steps through, carrying a strange spear with a blue glowing tip. Loki takes the Tesseract and uses the spear to take control of the minds of several SHIELD personnel, including Dr. Erik Selvig (Stellan Skarsgård) , and Agent Clint "Hawkeye" Barton (Jeremy Renner), to aid him in his getaway. SHIELD personnel pull out of their base when an energy surge from the Tesseract causes the ground beneath the base to collapse and destroying it. A short pursuit of Loki fails to capture him.
In response to the attack, Nick Fury issues a state of emergency, telling his top agents Phil Coulson (Clark Gregg), Natasha Romanoff (Scarlett Johansson), and Maria Hill (Cobie Smulders), that they are completely out of options. Fury pulls Romanoff and Coulson out of their respective assignments and sends them to find the heroes he needs to oppose Loki. Romanoff is found in Eastern Europe interrogating suspects, and Coulson pulls her off the assignment and sends her to find "the big guy": Bruce Banner (Mark Ruffalo), aka The Incredible Hulk. Banner has been living in exile in India working for a hospital in Calcutta helping sick people, and has found inner peace doing so. Romanoff tells Banner about the Tesseract and its' destructive capabilities. As the world's expert on gamma rays, Banner is their best chance to find the cube's location.
During a video chat with the World Security Council, the superiors who run S.H.I.E.L.D., Fury is grilled about his plan to bring about the Avengers Initiative. The WSC are furious, saying that it's the wrong thing to do and these people will never work together as a group. Fury says they have no other option and this is their only hope of defeating Loki. The superiors reluctantly agree.
Steve Rogers, (Chris Evans) on the other hand, is relatively easy to find. S.H.I.E.L.D. has been keeping tabs on him since he was found in the ice and still alive. Fury goes to greet Rogers at his gymnasium where he finds he doesn't sleep. Fury tells Rogers that he will find a briefing packet about what's going on back at his apartment. Tony Stark (Robert Downey Jr.) is seen in a new Iron Man armor that has underwater capabilities. He is installing a new electrical connection that will take his office building completely off the electrical grid allowing it to become self sustaining. He's greeted at his office by Pepper Potts (Gwyneth Paltrow) who tells him that it's date night. Tony wants Pepper to know how it feels to be a genius and after an argument about how much credit she should get for coming up with the Stark Tower idea, date night is off. Coulson arrives, and Tony quickly and repeatedly tries to cut him off. Coulson hands Tony a laptop with all the data on it about everything that's going on. Pepper decides instead to go to Washington DC to get the zoning permits for the next two buildings for Stark Tower as it seems Tony has homework to do, and a lot of it.
On the airplane to the secured location - an aircraft carrier that can convert to a flying aircraft carrier, Coulson is telling Rogers about how it's such an honor that they found him and tells him about his Captain America trading card collection. They then head to the helicarrier and Rogers is introduced to Dr. Bruce Banner. The two then wonder what kind of ride they're in for. Rogers thinks it's a submarine but the last thing Dr. Banner should be riding in is a submerged, pressurized metal container. The carrier takes off. On board, they are briefed that Dr. Selvig and Loki have been traced to Stuttgart, Germany.
Rogers' first assignment is to go to Stuttgart to arrest Loki and bring him on board the helicarrier. Loki is at a formal black tie gala at an art museum where he is kidnapping a doctor who harbors the element they need to make the Tesseract work. While Dr. Selvig creates a distraction and Hawkeye kills the men guarding the building, Loki carries out his plan. Outside, he is instructing the civilians present that they need to kneel before him - or else, and that freedom is life's great lie. However, one old man stands up in defiance, and Loki prepares to strike him down. However, the killing shot is neatly blocked by the shield of Rogers as Captain America before moving to confront the god. As Rogers battles Loki, Tony makes his entrance to the tune of AC/DC's "Shoot To Kill" with full Iron Man weapons drawn to knock down the god and daring Loki to make a move.
Loki quickly surrenders when the two heroes arrive, and while being flown to the high tech prison on board the helicarrier, the plane encounters a lighting storm. Rogers asks Loki if he's afraid of lighting but Loki tells him it's not the lightning that he's afraid of. It's what follows. Thor (Chris Hemsworth), Loki's half-brother and the Norse God of thunder, arrives and attempts to capture Loki so Loki can face Asguardian justice for his crimes (which will be more effective than Earth's), but Thor gets into a fight with Rogers and Tony. The fight ends in a stalemate. Eventually, Loki is taken to the helicarrier and placed in a glass cell designed to hold the Hulk. Fury explains that if Loki attempts to escape, even by merely cracking the glass, a shaft will open below him and he'll plummet to Earth and possibly be killed.
On board the aircraft carrier, the fully assembled Avengers squad is being briefed by Fury about what they think will possibly happen next. Loki is in prison and is interrogated by Agent Romanoff. Tony Stark arrives and it seems the only one of the group he really gets along with is Bruce Banner. While conducting experiments on Loki's scepter, Stark tries to get a rise out of Banner so he can witness Banner's famous party trick (read: turning into the Incredible Hulk). Banner flinches and then begins telling about how he's been unable to fully harness his abilities and that he suffered depression after the accident. That's why he moved to Calcutta, as helping people is what gives his life meaning.
The Avengers, now brought together, argue and deliberate over how to approach Loki and the revelation that SHIELD plans to harness the Tesseract's power to develop weapons, a discovery made by Rogers. Fury admits that the events in New Mexico a year before (recounted in Thor (2011)) made SHIELD aware of other races on other worlds, some of whom may see Earth as an easy target. Thor is seen asking agent Coulson about what happened to Jane Foster. Coulson tells him that S.H.I.E.L.D. has placed her in their witness protection program and that she's in a safe zone in London.
The decision was made to produce weapons with the Tesseract as a means of deterrence. As the group argues, Clint Barton and Loki's possessed agents attack the helicarrier, disabling one of its engines in flight. While Stark and Rogers attempt to restart the damaged engine, Romanoff tries to prevent Dr. Banner from turning into the Hulk and destroying the ship from inside. Her attempt fails and she's chased through the ship until Thor takes up the battle to pacify the beast and manages to fell him briefly with a hit from his hammer, Mjolnir. While fighting Barton, Romanoff slams him into a guard rail, and the blow to the head breaks Loki's mind control. After the Hulk falls from the ship, Thor is tricked into Loki's holding cell by Loki himself, who has recovered his scepter and releases the cell and allows Thor to plummet. Loki is held at bay briefly by Agent Coulson but is also tricked by one of Loki's holographic projections - Coulson is stabbed in the back by the real Loki. Coulson later shoots Loki with a blast from an unidentified weapon, one that harnesses the power of the Destroyer. Coulson dies while Fury tries to save his life. Thor escapes from the cell a split second before it hits the ground. Banner wakes up in his human form after crashing into an abandoned factory.
Fury uses Coulson's apparent death to motivate the Avengers to work as a team. Stark and Rogers realize that simply defeating them will not be enough for Loki. He needs to overpower them in a very public way so as to validate himself as ruler of Earth. Using a device built by Dr. Selvig, Loki opens a portal to the Chitauri home world over Manhattan, summoning a Chitauri invasion. Once again the group's petty differences overshadow their ability to communicate as a team, especially with Banner now missing. While in an argument with Rogers, Tony finally figures out that Loki is a full tilt diva, and that he's obviously set up shop at the top of Stark's office.
Natasha, unfortunately arrives too late just as Dr. Selvig has opened the portal. This unleashes Loki's army and all hell breaks loose. The army is massive and they can't all fight them off as much as they are entering the earth's atmosphere. Tony Stark thankfully shows up, as does Bruce Banner. While fighting, Rogers dispatches NYPD cops to direct citizens into the underground tunnels and sewers. Meanwhile, the Hulk smashes, and Tony arrives at Stark Tower where he attempts to stall Loki with a drink which is used to threaten and intimidate him. As that's going on, Tony has JARVIS prepare an under development version of Iron Man called MK18 which is contained in a giant box coded specifically for Tony and has advanced weapons capabilities. Loki refuses to cooperate, saying the destruction will continue as long as the citizens of earth don't get that they need to be ruled by him. Loki attempts to take control of Stark by using his scepter on his heart to control his mind, but it fails thanks to Tony's somewhat trusty Arc Reactor that keeps him alive.
The Avengers rally in defense of New York, but quickly come to the conclusion that they will be overwhelmed as wave after wave of Chitauri descend upon Earth. With help from the reformed Barton, Rogers and Thor evacuate civilians while Dr. Banner transforms into the Hulk and goes after Loki, beating him into submission in Tony Stark's penthouse. Romanoff makes her way, with a little help from the Chitauri, to the device that holds the portal open (conveniently located on the roof of the Stark Building) and hits Dr. Selvig over the head, freeing him of Loki's control. Dr. Selvig reveals that Loki's staff can be used to close the portal.
As that's happening, Hulk confronts Loki, who refuses to be intimidated by such a beast. As Rogers instructed, Hulk smashes Loki into near oblivion. That allows Romanoff to grab the scepter and head to the roof to shut down the portal. While Romanoff is securing the portal, Stark is securing the perimeter. Meanwhile, with Fury on a conference call to the council, Fury berates the council's decision to launch a nuclear missile at Manhattan. Fury tries everything possible to stop the council from launching nukes, even destroying two jets that are taking off from the helicarrier. Unfortunately as he's about to fire on a third, it gets away and launches a nuclear weapon.
Tony intercepts the missile and he knows exactly where to put it - he flies it into the portal. While in the portal, Stark instructs JARVIS to try Pepper one last time. Unfortunately the call fails as Pepper is on a plane and glued to the TV with other Stark Industries executives. Tony launches the nuke at the Chitauri mothership, completely destroying the invasion. All the invading aliens collapse and are rendered useless. Stark sees the nuke go just as he runs out of oxygen and falls to what appears to be certain doom. Thankfully he manages to escape the portal just as Romanoff is able to successfully close it. Once back in the atmosphere it looks like Tony isn't going to make it, but is saved by the Hulk thanks to incredible timing. A dazed Stark, awakened by the Hulk's roar, offers to take the team out for shawarma, but they decide to apprehend Loki first. The Avengers go their separate ways. Romanoff, Rogers, and Hawkeye return to working for S.H.I.E.L.D., Tony and Pepper are seen rebuilding Stark Tower and are working on the next phase of the project. Thor escorts Loki and the Tesseract back to Asgard where Loki will stand multiple trials for war crimes from both Asgard and the Chitauri. Meanwhile, multiple TV news reports recap the events surrounding the Avengers, and while they've become worldwide heroes for to some for their efforts in New York, others are fearful and want to know who will take responsibility for the devastation.
On another video conference call with the World Security Council, Fury is being congratulated, but they also grill him that now their secret's out, this group is too dangerous for the world to handle. And Fury is glad - what happened in New York is a warning. A warning to all galaxies that if they try to attack earth, S.H.I.E.L.D. is there to defend it. And they have just the team. Fury also tells the S.H.I.E.L.D. board that the Avengers' whereabouts are no longer being tracked. They've earned a leave of absence, but will be called back when needed. He also tells the council that the Tesseract is where no one on earth will ever be able to find it.
In a mid-credits scene, the Chitauri leader the Other tells his master that it is futile to attack Earth, as fighting the Avengers is like courting death. His master turns, revealing himself to be Thanos, a worshiper of the personification of Death, smiling at the chance to court her with more loss of life.
After further credits, the Avengers are shown eating together in a shawarma joint; the team looks worn out and no one speaks.