Major spoilers ahead for Avengers: Endgame. Being that we lost so many beloved characters at the end of Infinity War to Thanos' snap, the big question going into Endgame was how the remaining Avengers were going to undo his evil and get their friends back. Of course, there was always the possibility that they weren't going to bring those characters back to life. But considering that some of them, like Spider-Man, already have future movies in the works, and others, like Black Panther, have become so immensely popular, that possibility was always pretty low. How the Avengers reverse the snap is a pretty tricky and tragic quest.
There are two attempts at undoing the snap in Avengers: Endgame, but only one works out in the end. The film begins 23 days after the initial snap, and the universe is still reeling from the extreme trauma. The first plan, organized by remaining Avengers Black Widow, Hulk, Captain America, Thor, Rocket, War Machine, Nebula, and newcomer Captain Marvel track Thanos down to a very Eden-like planet where he seems to be living out the rest of his days. Their tech notes an incredible surge of power on the planet, similar to that of the snap, which means Thanos used the Gauntlet again. But when they arrive, they find out that Thanos had used the stones to destroy the stones. So not only are the stones gone, but as a result, they can't use them to undo the snap. In a fit of rage, Thor kills Thanos with his axe, Stormbreaker.
The film then jumps five years into the future. Black Widow is still running Avengers headquarters. Cap is leading survivor support groups, and Tony and Pepper live on a lake, raising their young daughter. But all that post-apocalyptic moving on is shattered when Ant-Man suddenly returns from the Quantum Realm with an idea as to how the Avengers can travel back in time to collect the stones from the past and undo Thanos' snap.
Cap, Iron Man, Ant-Man, and Hulk head to 2012 New York, where the Battle of New York from the original Avengers is in full swing. Hulk convinces Tilda Swinton's Ancient One to give him the Time Stone by revealing that Doctor Strange gave it to Thanos on purpose, somehow convincing her that his actions were intentional. They nab the Mind Stone out of Loki's scepter by Cap's quick thinking, whispering "Hail, Hydra" to the double agents taking it away. And even though they manage to collect the Tesseract a.k.a. the Space Stone as well, Loki eventually escapes with the blue cube. This leads to Captain America and Iron Man heading to New Jersey in 1970, where both the Tesseract and more Pym Particles for the journey home are being kept at a S.H.I.E.L.D Army base.
Elsewhere in the universe, Thor and Rocket go to 2013 Asgard to extract the Aether, aka the Reality Stone, from Jane Foster. Nebula and War Machine go to Morag in 2014 to steal the Power Stone before Star Lord gets there. And Black Widow and Hawkeye hit the same year on planet Vormir, where the Red Skull tells them the same thing he told Thanos: To obtain the Soul Stone, you must lose that which you love. Naturally, Nat and Clint love each other as extremely close friends, so they both offer to sacrifice themselves so that the other gets the stone. A fight ensues, which Black Widow wins, and Nat plummets off the cliff to her death, allowing for Hawkeye to return to reunite with the others, all six stones in hand.
Tony and Bruce then use Stark technology to create their own Infinity Gauntlet, which Bruce then wields, because his strength as the Hulk and previous exposure to Gamma rays make him the most capable choice. Bruce snaps his fingers, undoing the previous snap, but the effects aren't immediately apparent. Meanwhile, Thanos from 2014 has figured out their plan, unfortunately due to present day Nebula's mind link to the Nebula from the past (who's still loyal to him). He and his entire fleet jump forward in time, and the battle that follows offers some pretty awesome moments that you just need to watch to experience yourself.
But what's most satisfying is the fact that all of the snapped characters from Infinity War (and even some whose fate we didn't know) show up ready to fight. Shuri and T'Challa join Okoye with a fleet from Wakanda. Spider-Man returns to a huge embrace from Tony. The Guardians of the Galaxy return, and Doctor Strange brings his fellow wizards into the fold. But it's also noteworthy who isn't able to return. It seems like Black Widow and Gamora, who fell from the cliff in Vormir, as well as Vision, whom Thanos killed, weren't just trapped in whatever in between place the dusting took them all to (they return with their memories in tact), but are really gone for good.
It's super sad that it seems we have lost those three characters for good, but thankfully the Avengers manage to undo the snap in Endgame, so more are saved than lost.