The AsgardianLoki encounters the Other, the leader of an alien race known as the Chitauri. In exchange for retrieving the Tesseract,2 a powerful energy source of unknown potential, the Other promises Loki a Chitauri army with which he can subjugate the Earth. Nick Fury, director of the espionage agency S.H.I.E.L.D., and his lieutenant Agent Maria Hill arrive at a remote research facility during an evacuation, where physicist Dr. Erik Selvig is leading a research team experimenting on the Tesseract. Agent Phil Coulson explains that the object has begun radiating an unusual form of energy. The Tesseract suddenly activates and opens a portal, allowing Loki to reach Earth. Loki takes the Tesseract and uses his scepter to enslave Selvig and several agents, including Clint Barton, to aid him in his getaway.

In response to the attack, Fury reactivates the "Avengers Initiative". Agent Natasha Romanoff is sent to Calcutta, India to recruit Dr. Bruce Banner; Coulson visits Tony Stark to have him review Selvig's research; Fury approaches Steve Rogers with an assignment to retrieve the Tesseract. While Barton steals iridium needed to stabilize the Tesseract's power, Loki causes a distraction in Stuttgart, Germany, leading to a confrontation with Rogers, Stark, and Romanoff that ends with Loki's surrender. While Loki is being escorted to S.H.I.E.L.D., Thor, his adoptive brother, arrives and frees him hoping to convince him to abandon his plan and return to Asgard. After a confrontation with Stark and Rogers, Thor agrees to take Loki to S.H.I.E.L.D.'s flying aircraft carrier, the Helicarrier. There Loki is imprisoned while scientists Banner and Stark attempt to locate the Tesseract.

The Avengers become divided, both over how to approach Loki and the revelation that S.H.I.E.L.D. plans to harness the Tesseract to develop weapons as a deterrent against hostile extra-terrestrials. As the group argues, Barton and Loki's other possessed agents attack the Helicarrier, disabling its engines in flight and causing Banner to transform into the Hulk. Stark and Rogers try to restart the damaged engines, and Thor attempts to stop the Hulk's rampage. Romanoff fights Barton, and knocks him unconscious, breaking Loki's mind control. Loki escapes after killing Coulson and ejecting Thor from the airship, while the Hulk falls to the ground after attacking a S.H.I.E.L.D. fighter jet. Fury uses Coulson's death to motivate the Avengers into working as a team. Stark and Rogers realize that simply defeating them will not be enough for Loki; he needs to overpower them publicly to validate himself as ruler of Earth. Loki uses the Tesseract, in conjunction with a device Selvig built, to open a portal above Stark Tower to the Chitauri fleet in space, launching his invasion.

The Avengers rally in defense of New York City, but quickly realize they will be overwhelmed as wave after wave of Chitauri descend upon Earth. Rogers, Stark, and Thor evacuate civilians with assistance from Barton, while Banner transforms back into the Hulk and goes after Loki, eventually beating him into submission. Romanoff makes her way to the portal, where Selvig, freed of Loki's control, reveals that Loki's scepter can be used to close the portal. Meanwhile, Fury's superiors attempt to end the invasion by launching a nuclear missile at Manhattan. Stark intercepts the missile and takes it through the portal toward the Chitauri fleet. The missile detonates, destroying the invaders' lead ship which disables their forces on Earth. Stark's suit runs out of power and he falls back through the portal, but the Hulk saves him from crashing to the ground. Romanoff deactivates the portal to prevent further invasion. In the aftermath, Thor returns Loki and the Tesseract to Asgard. Fury notes that the Avengers will return when they are needed.

In the first of two post-credits scenes, the Other confers with his master3 about the attack on Earth; in a second scene, the Avengers eat in silence at a shawarma restaurant.