This week’s Avengers: Endgame wraps up what MCU mastermind Kevin Feige has dubbed the “Infinity Saga.” After the devastation of Infinity War, Endgame will reveal how the Avengers, you know, avenge the snapped population. But how did Marvel Comics own Infinity Saga end in the comics?

Unlike some of its predecessors (I’m looking at you, Avengers: Age of Ultron), Infinity War, and in theoretical turn, Endgame, are heavily inspired by the plot of certain Marvel comics. What happened between the pages? What will be the key differences? Before we know how the MCU plays out this major arc, here’s a look at how the story wrapped up on the page.

[Warning: The rest of this post contains major spoilers for Avengers: Infinity War.]

Infinity War pulls a few characters and trappings from the 2013 crossover comic Infinity, but it owes much more to Infinity Gauntlet, the original story of Thanos, the Infinity Gems and the big gold glove.

Infinity Gauntlet was a six-issue miniseries — with a few tie-ins here and there — written in 1991 by Jim Starlin and illustrated by George Pérez and Ron Lim. It is the story that made the Infinity Stones (or Gems, as they’re known in the comics) indelibly linked with Thanos and the Gauntlet, when the Mad Titan assembled all six and gained the ability to bend all of reality to his every whim.

To be fair, Marvel made some significant changes to the story of Infinity Gauntlet to bring it to the big screen. But it kept Thanos’ most significant act as a figure of omnipotence: the moment he erased half of the sentient population of the universe from existence.

And unlike Infinity War, Infinity Gauntlet kept going. Here’s what happened.

First, Thanos kills half the universe

After watching Infinity War, you might easily assume that the bulk of Infinity Gauntlet is also concerned with Thanos trying to acquire the Infinity Gems and the Avengers trying to stop him. But the first big difference between Infinity War and Infinity Gauntlet is that the whole “finding the Infinity Gems” part is over with before the story even begins.

Jim Starlin, Thanos’ creator, covered all of that in the limited series The Thanos Quest, in which the big purple guy defeated each Gem’s guardian. Infinity Gauntlet kicks off in a most impressive way: Thanos already has a fully loaded gauntlet in hand and is contemplating his newfound freedom as an omnipotent, cosmic ... well ...

And in the climax of the first issue, Thanos does the unthinkable: He snaps his fingers and murders half the universe. The literal disappearance of their loved ones is the first sign most of the Avengers get that anything is wrong at all.

What happens next?

Well, the other big difference between Infinity War and Infinity Gauntlet is that Thanos’ motivations are entirely different. In the comics, as you may have heard, Thanos is completely obsessed with winning the heart of Mistress Death, the anthropomorphic embodiment of the concept of death. That’s why he collected the Infinity Stones in the first place — because Death had ordered him to find a way to murder half of the universe.

In fact, most of the terrible things Thanos does with the Infinity Gauntlet are all about trying to impress a silent and uninterested Mistress Death. He kills half the universe, as she ordered. He traps his granddaughter Nebula in a living hell of pain to the point of death — without allowing her to die. He displays his helpless brother Eros for Death’s amusement, he transforms her cosmic fortress into a shrine to her worship and he fights the Avengers — turning Wolverine’s bones to rubber, suffocating Cyclops in an airtight cube, transporting Drax back in time into the age of dinosaurs, turning Thor to glass and shattering him — to prove his bravery.

Ultimately, all that reality tinkering attracts the attention of the most powerful cosmic entities of the Marvel Universe, who understandably view Thanos as a threat. And that’s where things start to go wrong for him.

How do the heroes get the Gauntlet away from him?

After the Avengers, Thanos’ cosmic rule is threatened by the supreme beings of the Marvel Universe; an all-star lineup including Galactus, Kronos, Epoch, the Living Tribunal, and a bunch of others like the personifications of concepts like Chaos and Order. It’s a tricky fight, but Thanos does prevail. And then, in the excitement of his triumph, he decides to transform himself into an astral entity and leave his corporeal form behind, which he believes will rid himself of his final vulnerability.

Unfortunately, he forgets that his godly powers are predicated on something very corporeal: His hand being inside the Infinity Gauntlet. Nebula, who has been mute and seemingly insensible to her surroundings after Thanos put her into an eternal state of living death, seizes her chance.

She yanks the gauntlet from Thanos’ abandoned body and shoves it onto her own hand, and now she’s the supreme being in the universe. She reforms her body into health, banishes Thanos into the depths of space and sets about struggling with her new infinite awareness of space and time.

In the meantime, the remaining forces of good wind up recruiting Thanos into a team-up to get the gauntlet from Nebula. She’s not exactly evil, but she isn’t exactly good either — and after Thanos’ abuse she was seriously traumatized. The universe was out of the frying pan of Thanos’ deliberate choices and into the fire of Nebula’s whims.

But when do they bring everyone back to life?!

I’m getting there! When a handful of remaining heroes — and Thanos — confront Nebula and ask her to give up the Gauntlet, she and Thanos fall into an argument. And to spite him, Nebula uses the Gauntlet to undo everything he did with it.

“With the exception that I retain possession of the Infinity Gauntlet, let everything be as it was 24 hours ago,” she cries.

Instantly, the universe is restored, Avengers are returned to life — and to their homes — loved ones are reunited throughout creation. Unfortunately for Nebula, the cosmic beings Thanos defeated are restored as well. And, again, they prove the distraction that our heroes need to disrupt the Gauntlet from within.

I could explain how they do that, but it’s very cosmic and involves a very powerful and yet pretty obscure superhero named Adam Warlock. He’s heavily involved in all of the Infinity Gem stuff in Marvel comics, but won’t show up in the Marvel Cinematic Universe until Guardians of the Galaxy Vol. 3 (theoretically). All you really need to know is that at the end of The Infinity Gauntlet, none of our core heroes or villains get to keep the Gauntlet and Thanos winds up living a quiet life on a backwater planet (a lot like at the end of Avengers: Infinity War).