With “Avengers: Endgame,” the two-movie story line that started with “Avengers: Infinity War” is finished, along with the 22-film cycle that represents the Marvel Cinematic Universe to date. And some of the heroes we’ve followed on this decade-long adventure are gone, too.

In the three-hour span of “Endgame,” the Avengers confront and kill Thanos (Josh Brolin), who had used the Infinity Gauntlet to snap away half of all life in the universe. When the story resumes five years later, the Avengers are still left with their grief and remorse — until the unexpected return of Ant-Man (Paul Rudd) kicks off a race back through time to retrieve the Infinity Stones before Thanos could obtain them in the first place. Black Widow (Scarlett Johansson) sacrifices her life; a colossal battle ensues; Iron Man (Robert Downey Jr.) dies; and Captain America (Chris Evans) finds a way to live the life he’d always wanted, reappearing as an old man to entrust his shield to the Falcon (Anthony Mackie).

These and many other head-spinning developments in “Endgame” emerged from the imaginations of its screenwriters, Christopher Markus and Stephen McFeely, who also wrote “Infinity War.” (Both films were directed by Joe and Anthony Russo.) Markus and McFeely have been friends and collaborators since the 1990s and also wrote all three “Captain America” movies as well as “Thor: The Dark World” (with Christopher L. Yost) and created the Marvel TV series “Agent Carter.”

In a recent interview in their offices in Los Angeles, Markus and McFeely discussed the many choices and possibilities of “Endgame,” the roads not taken and the decisions behind who lived and who died. These are edited excerpts from that conversation.

Deciding the Plot Points

How did you decide where the major events of “Infinity War” and “Endgame” would fall? CHRISTOPHER MARKUS The biggest point was probably the Snap. And we realized fairly early on that if we didn’t do it at the end of the first movie, the first movie wasn’t going to have an end. And if we did it too early in the first movie, it would be a bit of an anticlimax after you’ve killed half the universe to have them stumbling around for half an hour. STEPHEN McFEELY Another big plot point is when everyone comes back. So the question is, is it early in the second movie? Late in the second movie? You notice the players left on the board are the O.G. Avengers [Captain America, Iron Man, Thor, the Hulk, Black Widow and Hawkeye], and let’s give them their due. It meant that we were likely going to bring people back late. So that if you were a big fan of Doctor Strange or Black Panther or Bucky [the Winter Soldier] or Sam [the Falcon], you’re only going to get a little brief window on them. It can’t be all things to all people.

Image

The writers decided that the Thanos Snap, obliterating half of all human life, shouldn’t come too early in the first part of the concluding “Avengers” movies.CreditDisney/Marvel, via Associated Press

How did you choose which characters would survive for “Endgame”?

MARKUS We knew we wanted to see Cap and Tony dealing with the aftermath so that you could really see them suffer, quite frankly. And that’s why Cap and Natasha are relatively minimal in the first movie, because all they’d be doing is punching. We knew that they had a lot of story in the second movie, and there were other people who would have much more story in the first movie, like the Guardians. McFEELY Thor is strangely the one that gets two movies’ worth of story. MARKUS For a guy people once thought of as boring, he’s become very useful.

Image

Black Widow and Captain America were given less to do in “Avengers: Infinity War” because their story lines would be prominent in “Endgame.”CreditDisney

“Endgame” sort of tricks you by having the heroes kill Thanos almost immediately, only to discover it doesn’t solve anything. Why was that important? McFEELY We always had this problem. The guy has the ultimate weapon. He can see it coming. It’s ridiculous. We were just banging our heads for weeks, and at some point, [the executive producer] Trinh Tran went, “Can’t we just kill him?” And we all went, “What happens if you just kill him? Why would you kill him? Why would he let you kill him?” MARKUS It reinforced Thanos’s agenda. He was done. Not to make him too Christ-like, but it was like, “If I’ve got to die, I can die now.”

There’s a lot of bleakness and despair for roughly the first hour of the movie. Did that feel like a risk for a big-event picture? MARKUS It felt less risky once I saw the reaction to “Infinity War.” You never know how you’re going to hit people, emotionally. We’ve been sitting with these events for years. We no longer have an emotional reaction. And then you see people crying in the theater. We’ve got to honor that or it’s going to feel like we’re just jerking them around. McFEELY It was the part in test screenings where people were most uncomfortable. Because you are wallowing to a degree. There doesn’t seem to be any hope. In the end of Act II for most superhero movies, maybe they lose for five minutes. Here it’s for five years. That seemed important.

And that theme of loss is continued when Scott Lang visits a memorial to the dead in San Francisco. McFEELY We used to have beats in the script where there are those in every city. Millions of names.MARKUS It’s that sense of collective trauma and the fact that if you weren’t killed, you wake up the next day — the trauma happened and I’m still here. How do we deal with this? That was the Stan Lee trick. Where’s the anxiety coming from? Now that they have Power X.

Character Arcs

How did you start to determine the trajectories for the heroes in “Endgame”? McFEELY Chris and I wrote a master document while we were shooting “Civil War,” and one of the things we were interested in exploring is, remember the What If comics? Well, this is our what if. If you lost, Thor becomes fat. Natasha becomes a shut-in. Steve becomes depressed. Tony gets on with his life. Hulk is a superhero. MARKUS Clint becomes a murdering maniac. When we were spitballing for “Endgame,” we started with, Thor’s on a mission of vengeance. And then we were like, he was on a mission of vengeance in the last movie. This is all this guy ever does! And fails, all the time. Let’s drive him into a wall and see what happens. McFEELY He just got drunk and fat.

At least the Hulk is in a better place. MARKUS There was a time when Banner became Smart Hulk in the first movie. It was a lot of fun, but it came at the wrong moment. It was an up, right when everyone else was down. McFEELY It happened in Wakanda. His arc was designed like, I’m not getting along with the Hulk, the Hulk won’t come out. And then they compromise and become Smart Hulk. MARKUS We were like, but he’s Smart Hulk in the next movie. So that diner scene [in “Endgame”], was like, O.K., how do we smash right into that without scenes of him in a lab, gene-splicing? McFEELY Oh, I wrote scenes in a lab. Now it’s just him eating pancakes and I think it generally works. MARKUS The whole thing rides on Rudd going, “I’m so confused.”

Though Ant-Man didn’t participate in “Infinity War,” we saw how the Snap affected him in the tag for “Ant-Man and the Wasp.” How did you decide to pay this off in “Endgame”?McFEELY In late 2015 they say, you’re writing the 19th movie [“Infinity War”] and the 22nd movie. So we chose to make lemonade. And that was a big moment — we figured out we can withhold Ant-Man because he’s in his own movie. And their movie is not affected until the tag, and that just gives us a place to go [in “Endgame”]. You can do this when you’re planning ahead this much. The tone is all weird, right? Because that’s a light, fun movie and then we just kill everybody in the tag.

Hawkeye took arguably the darkest turn of any hero in this series.

McFEELY He’s a good example of people who had much stronger stories after the Snap. What was the story to tell with Hawkeye in the first movie that was different than anybody else’s? Leaving his family to go fight again? Yeah, he did that in “Civil War.” The hope is that he’s killing bad people.MARKUS There was a time where we contemplated having that archery scene in the first movie, after the Snap. You snap, and then you pop up in Clint’s farm — what are we watching? — and that’s the first indication it had a wider effect. But he literally had not been in the movie prior to that point. It’s cool, but it’s going to blunt the brutality of what [Thanos] did.McFEELY Joe [Russo] said we’ll put that up front in the second one.

Once you’d seen how successful “Black Panther” and “Captain Marvel” were, did you try to find more opportunities for the characters from those films? McFEELY There wasn’t a lot of time to adjust. It’s not like we could say, “Hurry, put Shuri in there.” We started [filming “Infinity War” and “Endgame”], and then “Black Panther” started, we’re still going. They finish. We’re still going. MARKUS “Panther” comes out. McFEELY When we’re doing the tests [before “Black Panther” opened], and Cap goes, “I know somewhere,” and then you cut to Wakanda, the audience goes, “Oh, that’s interesting.” But when you do those tests after the movie comes out, all you have to do is [makes drumming noises] and people freak out. Same issue with “Captain Marvel.” We shot [Brie Larson] before she shot her movie. She’s saying lines for a character 20 years after her origin story, which no one’s written yet. It’s just nuts.

MARKUS She’s been in space nearly half her life. She has obligations. McFEELY Certainly, Captain Marvel is in [“Endgame”] a little less than you would have thought. But that’s not the story we’re trying to tell — it’s the original Avengers dealing with loss and coming to a conclusion, and she’s the new, fresh blood.

Were there any Marvel characters you wanted for these movies that you couldn’t have? MARKUS We did try to put the Living Tribunal in the first movie. We wrote a scene in which he appeared during the Titan fight. And everyone was like, what? McFEELY Whoa. He’s got three heads. It would indicate a whole different level of architecture to the universe and I think that was too much to just throw in. MARKUS The idea’s still in [Marvel Studios President] Kevin [Feige]’s court. McFEELY Oh sure, we probably just spoiled it. MARKUS The Living Tribunal has his own streaming show. McFEELY It’s like “Judge Judy.”

Adventures in Time Travel

Early in “Endgame,” the movie jumps ahead five years. Was that inspired by some TV series that have also used this device? MARKUS That was what we bought ourselves by ending the last movie the way we did. We wanted it to be real and for a long time — both in movie time and in chronological time for the characters. You couldn’t end Natasha, Tony and Steve the way we do without knowing that they’ve done their time and this is taking them to the brink. McFEELY We talked about “Fargo” from the first season, where it just jumps a year. And you go, “Whaaaaat?” We hopefully get a similar reaction. MARKUS And when “Lost” had their flash forwards, you were like, how’d that happen?

Where did the idea for the time-travel story line come from? McFEELY Kevin [Feige] at one point said, I would like to use the Time Stone, or use time as an element. It let us spend a few weeks seeing what’s the kookiest thing we could do with time and not break the movie. MARKUS We all sat there going, really? We’re going to do time travel? It was only when we were looking at who we had available, character-wise; we hadn’t used Ant-Man yet. And there really is, in people’s theory of the Quantum Realm, a time thing in the M.C.U., right now, available to us, with a character we haven’t used yet. We have a loophole that’s not cheating.

It’s crucial to your film that in your formulation of time travel, changes to the past don’t alter our present. How did you decide this? MARKUS We looked at a lot of time-travel stories and went, it doesn’t work that way. McFEELY It was by necessity. If you have six MacGuffins and every time you go back it changes something, you’ve got Biff’s casino, exponentially. So we just couldn’t do that. We had physicists come in — more than one — who said, basically, “Back to the Future” is [wrong]. MARKUS Basically said what the Hulk says in that scene, which is, if you go to the past, then the present becomes your past and the past becomes your future. So there’s absolutely no reason it would change.

Image

Chris Pratt in a scene from “Guardians of the Galaxy” that is revisited in “Endgame.”CreditJay Maidment/Marvel Studios and Walt Disney Pictures

Did you try any other approaches to the time-travel story? McFEELY In the first draft, we didn’t go back to the [original] “Avengers” movie. We went back to Asgard. But there’s a moment in the M.C.U., if you’re paying very close attention, where the Aether is there and the Tesseract is in the vault. In that iteration, we were interested in Tony going to Asgard. He had a stealth suit, so he was invisible, and he fought Heimdall, who could see him.MARKUS Thor had long scenes with Natalie Portman. And Morag [the planet where Peter Quill finds the Orb] was hugely complicated. McFEELY It was underwater! That was clever but it was just too big a set piece. What that didn’t do is allow for Thanos and his daughters to get on the trail at the right moment. So we went back to when Peter Quill was there. And we realized that when you can punch Quill in the face, it’s hilarious. I still think it’s hilarious. MARKUS There were entirely other trips taken. They went to the Triskelion at one point to get the [Tesseract], and then somebody was going to get into a car and drive to Doctor Strange’s house.McFEELY Just saying it out loud, it’s like, what are we doing? MARKUS It was when we were trying to avoid going to “Avengers” because it seemed pander-y.McFEELY We’re not always right. MARKUS The obvious ones seemed so obvious that it’s too obvious. McFEELY Eventually, Joe Russo went, why are we going to this movie when we can go to “Avengers?” Let’s make it work.

Thor recovers his hammer, Mjolnir, by taking it from an earlier timeline. So that raises the question — McFEELY Does that screw that other Thor? MARKUS Is he killed by Dark Elves? McFEELY I think we’re leaning on, when you just take a baseball mitt, you didn’t ruin that kid’s life. When you took Mjolnir, we accept that that movie happened. Because time is irrefutable. MARKUS You can make any number of what ifs. The Dark Elves would have arrived, intending to get the Aether. It’s what they came for and it was no longer there. McFEELY So they build a paradise together. MARKUS They all got married. [laughter]

There’s a surprise cameo, in the “Avengers” scene, from Robert Redford as Alexander Pierce. Did you prepare for other scenarios if Redford wasn’t available? McFEELY That was one where we thought, should it be Nick Fury? We also wrote a version for Maria Hill. That whole time, they’re announcing “Old Man With a Gun” as Redford’s last appearance on film. It’s the last time you’re going to see Robert Redford. And we’re going — [shoots conspiratorial look at Markus] [Laughter]

Image

Robert Redford, opposite Chris Evans in “Captain America: The Winter Soldier,” was brought back for the latest movie.CreditMarvel Studios and Walt Disney Pictures

The Final Battle

How did Marvel feel when you told them you envisioned a massive battle royal with nearly every character from the franchise? MARKUS I think they knew it was coming. McFEELY It’s why it took so long. We shot for 200 days for two movies. MARKUS We wrote and shot an even much longer battle, with its own three-act structure.

Were there scenes you wrote for this sequence that didn’t make it into the film? McFEELY It didn’t play well, but we had a scene in a trench where, for reasons, the battle got paused for about three minutes and now there’s 18 people all going, “What are we going to do?” “I’m going to do this.” “I’m going to do this.” Just bouncing around this completely fake, fraudulent scene. When you have that many people, it invariably is, one line, one line, one line. And that’s not a natural conversation. MARKUS It also required them to find enough shelter to have a conversation in the middle of the biggest battle. It wasn’t a polite World War I battle where you have a moment.

How did you coordinate the moment where all the female Marvel heroes come together? McFEELY There was much conversation. Is that delightful or is it pandering? We went around and around on that. Ultimately we went, we like it too much. MARKUS Part of the fun of the “Avengers” movies has always been team-ups. Marvel has been amassing this huge roster of characters. You’ve got crazy aliens. You’ve got that many badass women. You’ve got three or four people in Iron Man suits.

Were there other characters you could’ve had but didn’t use? MARKUS There were moments, as they brought everybody back, where we’re like, technically, Michael Douglas and Michelle Pfeiffer have [Ant-Man] suits. Do we bring them back? It became impossible to track the people we did bring back, but also, it’s just going to be an orgy. McFEELY Do you put Luke Cage in there?

Image

Mike Colter, left, Krysten Ritter and Charlie Cox in the Netflix series “Marvel’s The Defenders.”CreditJessica Miglio/Netflix

Did you consider using the heroes from the Netflix TV shows, like Daredevil or Jessica Jones? McFEELY We would have to introduce these five characters — or whatever many. We already are assuming people have seen a lot of the movies. Are we really going to assume they have bought a subscription to Netflix and watched those shows enough so that when they see them, they’re going to go “yay?” MARKUS It also screws up the timelines. You would have to assume that they all got snapped away, or otherwise they might have shown up earlier. I think the only character who has come from TV to the movies is Jarvis, James D’Arcy [from “Agent Carter”].

Could you have used any of the characters that Disney obtained from the Fox acquisition, like the X-Men or Fantastic Four? McFEELY Legally, not allowed to. MARKUS I guess it’s done now but it wasn’t done then. They still have an “X-Men” movie [“Dark Phoenix,” due in June]. You can’t reboot them before they’re done. “Sorry to completely screw you.”

Image

Sophie Turner as Dark Phoenix, one of the X-Men, off-limits for the “Avengers” series.CreditTwentieth Century Fox

“Endgame” shares some unexpected parallels with “Game of Thrones,” which also recently ran episodes about its heroes preparing for a significant battle and then the battle itself. Why do you think these narratives are similar? Did you ever look at “Game of Thrones” for inspiration? MARKUS We’re in a high-stakes time and a jarring time in history, where you have to contemplate what you’re willing to do to improve the situation. Whether or not everyone’s speaking to that, or just good old-fashioned storytelling, I don’t know. McFEELY Marvel has been accused of being the most expensive television show there is, and there’s some truth to that. The genres are different, the tones are different, but it’s serialized storytelling.MARKUS We occasionally wonder, did we just make the world’s most expensive inside-baseball fan service? But then we go, the fans are actually the majority of people who come to this. It’s inside baseball, but everyone is following the baseball. That’s also why the Marvel characters have lasted this long. They’re weird. They have strange quirks. McFEELY The bland ones don’t last. MARKUS I remember “Game of Thrones” being a reference for the first movie. How far apart can you keep these strands, and for how long, and still feel like you’re telling a single narrative? “Game of Thrones” has people who are just meeting now! As much as people think the culture’s going down the drain, there seems to be an elevating of people’s estimating of the kind of narrative that will succeed in popular culture. McFEELY Whatever you think of this movie, it’s complicated. It is not another sequel. MARKUS And a lot of popular TV is complicated. “This Is Us” is complicated. “Simon & Simon” was not that complicated. Great as it was. But it does seem like there is an acceptance of more complicated forms of storytelling.

Was the three-hour running time of “Endgame” ever in question? MARKUS There was an agreement within the whole group that we’re going to take our time; we’re not going to cut a half-hour of it so we can get one more screening in per day. McFEELY We couldn’t! Where are you going to cut a half-hour? There was not a sequence you could cut. MARKUS Look at some of the most popular movies of all time. They’re long as hell. When people want to see something, it doesn’t seem to get in their way. There’s some short, totally unsuccessful movies, too.

Journey’s End

Why does Natasha Romanoff have to die? McFEELY Her journey, in our minds, had come to an end if she could get the Avengers back. She comes from such an abusive, terrible, mind-control background, so when she gets to Vormir and she has a chance to get the family back, that’s a thing she would trade for. The toughest thing for us was we were always worried that people weren’t going to have time to be sad enough. The stakes are still out there and they haven’t solved the problem. But we lost a big character — a female character — how do we honor it? We have this male lens and it’s a lot of guys being sad that a woman died. MARKUS Tony gets a funeral. Natasha doesn’t. That’s partly because Tony’s this massive public figure and she’s been a cipher the whole time. It wasn’t necessarily honest to the character to give her a funeral. The biggest question about it is what Thor raises there on the dock. “We have the Infinity Stones. Why don’t we just bring her back?” McFEELY But that’s the everlasting exchange. You bring her back, you lose the stone.

Was there a possible outcome where Clint Barton sacrifices himself instead of her? McFEELY There was, for sure. Jen Underdahl, our visual effects producer, read an outline or draft where Hawkeye goes over. And she goes, “Don’t you take this away from her.” I actually get emotional thinking about it. MARKUS And it was true, it was him taking the hit for her. It was melodramatic to have him die and not get his family back. And it is only right and proper that she’s done.

Image

Black Widow and Hawkeye face very different endings.CreditMarvel Studios

And Tony Stark has to die as well? McFEELY Everyone knew this was going to be the end of Tony Stark. MARKUS I don’t think there were any mandates. If we had a good reason to not do it, certainly people would have entertained it.McFEELY The watchword was, end this chapter, and he started the chapter.MARKUS In a way, he has been the mirror of Steve Rogers the entire time. Steve is moving toward some sort of enlightened self-interest, and Tony’s moving to selflessness. They both get to their endpoints.

Were there any other outcomes you considered for Tony? MARKUS No. Because we had the opportunity to give him the perfect retirement life, within the movie. McFEELY He got that already. MARKUS That’s the life he’s been striving for. Are he and Pepper going to get together? Yes. They got married, they had a kid, it was great. It’s a good death. It doesn’t feel like a tragedy. It feels like a heroic, finished life.

And Cap was always going to be allowed his happy ending with Peggy Carter? McFEELY From the very first outline, we knew he was going to get his dance. On a separate subject, I started to lose my barometer on what was just fan service and what was good for the character. Because I think it’s good for the characters. But we also just gave you what you wanted. Is that good? I don’t know. But I’ll tell you, it’s satisfying. He’s postponed a life in order to fulfill his duty. That’s why I didn’t think we were ever going to kill him. Because that’s not the arc. The arc is, I finally get to put my shield down because I’ve earned that. MARKUS A hero without sacrifice, you’re not going to get the miles out of that person that you need to for these movies. That’s what makes them a hero, it’s not the powers.

Image

Anthony Mackie seems to be in line to take up the Captain America shield.CreditZade Rosenthal/Marvel Studios and Walt Disney Pictures

“Endgame” sets up Sam Wilson as the new Captain America. Is that a future Marvel film? Would you write that? MARKUS We really do just know what you know. They’re doing “The Eternals,” which is a property I know next to nothing about. We’ve been here, trying to set this contraption running. Were we to take another one on, you can’t increase the scope or the stakes from where we are at the moment. We’d have to shrink it back down, do an origin story. There are deep-bench characters where I’m like, if you roll that guy out, I couldn’t resist. There is a great Moon Knight movie to be made, but I don’t know what is.

You’ve been writing these films and characters for more than a decade, and you never got bored of them — McFEELY Or fired. For sure. MARKUS We’ve come close to both. It’s a testament to the concept but also the people we’re working with. We’re not bumping up against this dictatorial level where it’s like, “I have some notes. I really want to see him fly a dragon — put the dragon in. I’m going to lunch.” McFEELY If we have an idea, people take it really seriously. They valued “Winter Soldier” and they saw how “Civil War” was coming together. They’d seen our process and us working with the [Russo] brothers, and they said, if Joss [Whedon] is not coming back — I don’t know that decision — it was clear that, unless they hated us, it was going to be this team. MARKUS But there also was a possibility, because [“Avengers: Age of Ultron”] made a little bit less than “Avengers” 1 — that we were taking on “Superman” 3 and 4. Maybe people were done with it. McFEELY The goal was not to advance it to the stratosphere. It was to just not screw it up.

Is this your Marvel finale as well? MARKUS I don’t know how to follow it up, that’s the problem. I’m not quite old enough to retire.

If “Endgame” has taught us anything, it’s that you should never retire. McFEELY Then they drag you out and kill you.

A version of this article appears in print on , on Page AR24 of the New York edition with the headline: ‘Avengers: Endgame’ Screenwriters Tell All. Order Reprints | Today’s Paper | Subscribe