Three weeks after
Thanos used the
Infinity Stones to disintegrate half of all life across the universe,
[N 1] Carol Danvers rescues
Nebulaand
Tony Stark from deep space. They return to Earth and join the remaining
Avengers—
Natasha Romanoff,
Bruce Banner,
Steve Rogers,
Rocket,
Thor, and
James Rhodes. They track down Thanos to an uninhabited planet where he is living alone as a farmer. Now-injured Thanos tells them that he destroyed the Infinity Stones to make the culling of the Universe irreversible. Thor beheads Thanos.
Five years later,
Scott Lang escapes the
quantum realm[N 2] and meets Romanoff and Rogers at the Avengers' compound. Only five hours have passed for Lang instead of years, and he proposes going back in time via the quantum realm to stop Thanos. They ask Stark for help, but Stark refuses because he now has a daughter and worries what messing with the timeline might do to her. They then turn to Banner (who has learned to control his Hulk aspect), and he agrees to help them develop a time machine. Stark eventually has a change of mind and helps Banner complete the project.
With new hope, Banner and Rocket travel to Norway, where the survivors of Asgard have established a small fishing community. There, they find Thor, who has become a fat drunk, and convince him to rejoin the Avengers. Likewise, Romanoff travels to Japan, where Barton has become a vicious vigilante, and convinces him to return.
The reunited Avengers split into several groups. Banner, Rogers, Lang, and Stark travel to New York City in 2012.
[N 3] Banner visits the
Sanctum Sanctorum and convinces the
Ancient One to give him the Time Stone. The Ancient One tells Banner that the Stones must eventually be returned to their original time frames to prevent reality from breaking down. Rogers manages to steal Loki's sceptre (which contains the Mind Stone), but Lang and Stark's attempt to steal the Tesseract (the Space Stone) fails and
Loki escapes with it. Rogers and Stark use the last of their size-altering Pym Particles to travel to
S.H.I.E.L.D. headquarters in 1970; they steal an earlier version of the Tesseract from the vault and some vials of Pym Particles from
Hank Pym's lab so they can return to the present.
Rocket and Thor travel to
Asgard in 2013 to extract the Aether (the Reality Stone) from
Jane Foster,
[N 4] and Thor obtains his former hammer,
Mjolnir. Barton and Romanoff travel to
Vormir in 2014 and learn from the Soul Stone's keeper, the
Red Skull, that it can only be acquired by sacrificing someone they love. After a fight, Romanoff sacrifices herself. On Morag in the same year, Nebula and Rhodes steal the Orb before
Peter Quill can.
[N 5] Rhodes returns to the present with the Power Stone, but Nebula is unable to after her cybernetic implants interface with those of her 2014 self. Through this connection, Thanos accesses future-Nebula's memories and learns of the Avengers' plans. He sends the 2014 Nebula to the present disguised as future-Nebula.
With all the Infinity Stones collected in the present, Banner uses them to resurrect everyone whom Thanos disintegrated. The 2014 Nebula uses the time machine to transport Thanos and his ship to the present day, and he attacks the Avengers' compound. 2014 Gamora gains compassion for and frees future-Nebula, who then confronts and shoots her 2014 version dead. Thanos then teleports to the surface to fight the Avengers in person. He tells them that he will use the Infinity Stones to destroy the Universe and create a new, better one, and nobody will remember the old one. Thanos overpowers the Avengers and summons his army to lay siege to Earth.
Stephen Strange arrives with reinforcements, including his fellow sorcerers, the other restored Avengers, the
Guardians of the Galaxy with Nebula beside them, and the armies of Asgard,
Wakanda, and the Ravagers. They fight Thanos' army, and are eventually joined by Danvers, who destroys Thanos' ship. Stark uses the Infinity Stones to disintegrate Thanos and his army, but the energy feedback kills him.
Following a funeral for Stark, Thor appoints
Valkyrie as the queen of New Asgard and joins the Guardians of the Galaxy. Rogers returns the Infinity Stones and Mjolnir to their original places in time and then remains in the past to be with
Peggy Carter. In the present, an elderly Rogers passes on
his shield to
Sam Wilson.