After his fall from Asgard into space, the Asgardian Loki meets the Other, the leader of a warmongering 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., arrives at a remote research facility during an evacuation. Physicist Dr. Erik Selvig is leading a research team experimenting on the Tesseract, and Agent Maria Hill 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 staff 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 India to recruit Dr. Bruce Banner; agent Phil Coulson visits Tony Stark to have him review Selvig's research; and 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 being escorted back to S.H.I.E.L.D., Thor, Loki's adoptive brother, arrives and frees Loki hoping to convince him to abandon his plan and return him 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, and imprison him until the Tesseract can be acquired.
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 of mass destruction 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 Thor and the Hulk are each ejected from the ship. 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. With help from Barton, Rogers, Stark, and Thor evacuate civilians, while Banner transforms into the Hulk again 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 staff 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, thereby disabling 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 master about the attack on Earth; in a second coda, the Avengers eat in silence at a shawarma restaurant.