Warning: Spoilers for Avengers: Endgame ahead!
By the time the credits roll on Avengers: Endgame, our heroes have finished the final battle against Thanos. It's not without heavy losses of longtime characters, but in the end, the universe is saved. Here's a breakdown of exactly how they did it.
Mission: Time Heist
The snap from Infinity War is undone when the team assembles the Infinity Stones via time-travel shenanigans. The team revisits history at several points to grab the Infinity Stones before Thanos does, costing the life of Natasha along the way but ultimately successful in bringing the Stone back. Professor Hulk uses a new gauntlet, that victory only lasts momentarily. Unbeknownst to them, Nebula is actually a past version of herself who sneaks along for the ride and is still loyal to Thanos. The Mad Titan himself arrives from the past, thanks to a smuggled vial of Pym particles, and brings his whole army along. Knowing now that his "snap" is not appreciated by the denizens of the universe, he's decided to simply wipe out the entire universe and build from scratch instead of leaving half the original inhabitants behind.
That doesn't sit well with the Avengers, but they're temporarily incapacitated by Thanos's almost instant destruction of their compound. While Clint flees through the tunnels with the Infinity Gauntlet, Thor, Tony, and Steve head out to face down Thanos, wielding their usual weapons. They make a valiant effort, but are knocked out one by one. Thor attempts to use his axe, Stormbreaker, but Thanos gains the upper hand. That's when Mjölnir comes back into play — with Cap wielding the iconic hammer (much to Thor's delight). This gives them a second wind, but Thanos again beats them back, leaving Cap alone, with a broken shield, versus Thanos and his entire army.
Avengers . . . ASSEMBLE!
That's when Steve gets an unexpected call through his comm link: "On your left." Sure enough, a portal opens up on Cap's left and the cavalry arrives, led by a newly-resurrected Sam Wilson. And by the cavalry, we mean every single hero who was brought back from the snap, plus all of their allies. Sam, Bucky, and Spider-Man arrive, Pepper joins the fray in her Rescue armor, Wanda brings her magic to the fight, T'Challa, Shuri, and Okoye bring basically all of Wakanda with them, Valkyrie leads the survivors of Asgard, the Guardians of the Galaxy and their cosmic allies arrive, and Doctor Strange brings every sorcerer imaginable.
As the battle commences, the most important focus becomes getting the Infinity Stones out of Thanos's reach and back where they belong in time. While Scott and Hope work to repair the time portal in their van, the rest of the team takes turns keeping the gauntlet safe from Thanos and his army. What follows is the most epic game of hot potato ever put on film: Clint passes the gauntlet to T'Challa, who fights his way out from underneath Thanos's army until Ebony Maw literally pulls the ground out from under him. Then Peter swings by and grabs it, and Pepper and Valkyrie help him stay in the air until he's knocked back to earth. Finally, Captain Marvel gets the gauntlet from Peter and, with the help of every female hero, begins smashing through the ranks.
The Final Standoff
Ultimately, though, Thanos still gets his hands on the Infinity Stones, and only a tired, battered Tony stands in the way, grappling at the gauntlet unsuccessfully. Thanos makes a final boast that his win is inevitable, and snaps his fingers — only for nothing to happen. Tony reveals that, during their seemingly futile struggle, he got the Stones out of Thanos's gauntlet and into his own. Even though the energy it takes will be fatal, Tony uses the Stones to snap Thanos and his army into dust, saving the universe at the cost of his own life.
With that, the overarching villain of the entire Marvel Universe to date is gone, the battle is won, and the Marvel universe is sent into a new and uncertain future.