Warning: Spoilers ahead for HBO's "Game of Thrones."

After running out of published material from George R.R. Martin's book series, the "Game of Thrones" showrunners David Benioff and D.B. Weiss have been making their own choices for key characters.

Arya killing the Night King is emblematic of how Benioff and Weiss' adaptation has moved away from Martin's carefully plotted narratives and closer to their invented storylines.

The show's overtaking the books made the heated, divisive reaction to these final episodes inevitable.

Visit INSIDER's homepage for more stories.

On the third episode of the final "Game of Thrones" season, Arya Stark stabbed the Night King with a Valyrian steel dagger, exploding him into ice-dust and thereby destroying the entire army of the dead and every White Walker.

And with that action, a schism erupted in the "Game of Thrones" fandom, uncovering a mess of emotions about HBO's adaptation of George R.R. Martin's "A Song of Ice and Fire" series.

When you start scratching the surface of how Arya came to that moment in the godswood, and how "Game of Thrones" as a whole has come to its end, it's clear why the backlash was inevitable, no matter what choice the show made in its final six episodes.

The show started as a true adaptation of George R.R. Martin's 'A Song of Ice and Fire'

Arya Stark and her father, Ned, on season one of "Game of Thrones." HBO

"Game of Thrones" is an adaptation of a fantasy book series by Martin titled "A Song of Ice and Fire." Martin began publishing the series in 1996 and has completed only five of the planned seven books.

Martin signed over the rights to his story to David Benioff, D.B. Weiss, and HBO in the mid-2000s. At the time, both Martin and the newly appointed showrunners for "Game of Thrones" believed he would finish his book series well before the TV adaptation caught up to him.

Everyone was wrong.

Around the third season of the show, Benioff and Weiss saw how "Game of Thrones" was closing in on the published books. By the end of the fifth season, they would be virtually out of written material from Martin to help guide their scripts.

George R.R. Martin and David Benioff in 2010. Frederick M. Brown/Getty Images

So they arranged a meeting with Martin, and he gave them a general outline of his plan for the series' ending and the fates of each of the main characters.

"Certain things that we learned from George way back in that meeting in Santa Fe are going to happen on the show, but certain things won't," Benioff told Time magazine in 2017. "And there's certain things where George didn't know what was going to happen, so we're going to find them out for the first time too, along with millions of readers when we read those books."

'Game of Thrones' diverged on its own path around the 6th season

Arya killing the Night King was not one of the things Martin told Benioff and Weiss, because the Night King doesn't even exist as a character in his book series. Martin has scarcely shown the White Walkers in his published chapters, let alone a White Walker leader.

In an HBO "The Game Revealed" segment, Benioff said they decided a few years ago that Arya would kill the Night King.

"For, oh God, I think it's probably three years now or something we've known that it was going to be Arya who delivers that fatal blow," Benioff said.

Maisie Williams as Arya Stark fighting at the Battle of Winterfell on "The Long Night." Helen Sloan/HBO

Not knowing precisely when that interview was filmed, we approximate that the decision was made around 2016, when the sixth season of "Game of Thrones" was in production. The sixth season also happened to be when the series truly started striking out on a narrative that diverged from Martin's book series.

Jon Snow's resurrection was likely told to Benioff and Weiss by Martin (since the impermanence of his death had been foreshadowed heavily in the text), but the books have staged Stannis, not Jon and Sansa, as the one who will fight Ramsay Bolton's forces.

Another major season six moment Benioff and Weiss invented was Cersei blowing up the Sept of Baelor and wiping out a handful of major characters, namely almost all of House Tyrell. After that episode aired, Weiss seemed to indicate that Cersei's storyline was born from a need to both push her character forward and use plot devices they had already worked into the show from earlier seasons.

In the books, Cersei only just finished her Walk of Atonement. HBO

"At this point in the story, we're trying to kind of play with the pieces that we've got on the board," Weiss said on HBO's "Inside the Episode" video. "The wildfire was something we had on the board."

The wildfire was included on seasons two and three, for the Battle of the Blackwater and then mentioned by Jaime Lannister during his memorable bathtub monologue to Brienne of Tarth.

Even though Martin had told Benioff and Weiss the broad strokes of where the main cast of characters ends up, he didn't tell them how they got there. Even Martin, who has described himself as a "gardener" kind of writer, didn't know the precise pathways for his characters.

So Benioff and Weiss were on their own to chart the way to the finale and therefore turned to certain seeds they had planted on earlier seasons, as they did for Cersei's solution to being cornered in King's Landing.

We can see now how they also turned to earlier pieces of the series to find the forward for Arya Stark.

The selection of Arya and the Valyrian dagger as the final undoing of the Night King

Arya is still in Braavos in the books. HBO

In Martin's books, Arya is still in Braavos with the Faceless Men. Many book readers believe the story will lead her back to Westeros at some point, but the how and why are unclear.

But the sixth season of "Game of Thrones" was all about Arya breaking from the Faceless Men and deciding to head back to Westeros. Again, by this stage of production, Benioff and Weiss had decided they wanted Arya to kill the Night King, so they clearly needed to start positioning her to do so.

On the sixth season finale, Arya had left Braavos and arrived in Westeros to assassinate Walder Frey. Arya's arc on the seventh season was focused on getting her to Winterfell, reuniting her with the remaining Starks, and giving her the Valyrian steel dagger (more on that in a bit).

Following the Battle of Winterfell episode, the two showrunners provided more details about why they picked Arya as the character to vanquish the Night King.

"We hoped to kind of avoid the expected," Benioff said in HBO's "Inside the Episode" segment. "Jon Snow has always been the hero and the one who's been the savior, but it just didn't seem right to us for this moment."

"We knew it had to be Valyrian steel, to the exact spot where the Child of the Forest put the dragonglass blade to create the Night King," Benioff continued. "And he's uncreated by the Valyrian steel."

In HBO's other behind-the-scenes video, "The Game Revealed," Benioff said they had known "for a long, long time" that that particular Valyrian dagger would "end the Night King."

By the time the seventh season rolled around, they had started planting clues about both Arya and the Valyrian dagger's destiny with the Night King.

"When Samwell's reading the book about dragonglass, there is a picture of the dagger," Weiss said in the "Game Revealed" video. "It is very possible that the same thing that created the Night King is the thing that was necessary to destroy the Night King. Or maybe it's Valyrian steel. Figure it out for yourself; I'm not going to say."

The Valyrian dagger was seen in one of the Citadel books. HBO

When Sam is reading the book showing the dagger, he says, "The Targaryens used dragonglass to decorate their weapons without even knowing what the First Men used it for."

Based on Weiss' cryptic hint and the line they wrote for Sam during that important page-turning moment, it's possible the dagger Arya used worked on the Night King only because it was made from both Valyrian steel and dragonglass.

Isaac Hempstead Wright, who plays Bran Stark, also hinted to INSIDER that he was directed to play the moment when Bran hands Arya the dagger as having a loaded significance for the future.

Benioff and Weiss picked 2 key scenes they invented early on the show to 'retcon' Arya's actions

To help spur Arya's assassination of the Night King and build the surprise into part of the Battle of Winterfell's narrative structure, Benioff and Weiss brought Melisandre back into the fold. She served several important purposes for the episode, including bringing the full might of the Lord of Light's fire powers against the threat of darkness presented by the Night King and his army.

Melisandre and Arya on "The Long Night." Helen Sloan/HBO

But most of all, Melisandre is one of those "pieces" Benioff and Weiss knew they had on the board, and it helps that she has a bit of prophetic power already baked into her character as written by Martin.

Melisandre was able to give Arya (and therefore the audience) a reminder of two important moments from earlier on the series.

First, Melisandre repeated the premonition she told Arya on season three.

"I see a darkness in you," Melisandre said. "And in that darkness, eyes staring back at me. Brown eyes, blue eyes, green eyes, eyes you'll shut forever. We will meet again."

Melisandre and Arya never meet in the books, so this scene stood out to fans of Martin's novels when it aired in 2013. The added mention by Melisandre that she'd meet Arya again left people curious, but the comment about her shutting eyes forever seemed to simply be a nod to her future deadly endeavors as a Faceless Man.

Melisandre's scene with Arya on season three. HBO

Benioff and Weiss changed up the order of the eye color when Melisandre repeated this line to Arya on "The Long Night," putting "blue eyes" at the end so Melisandre could clearly spur Arya on to her assassination side-mission.

To really hammer in the point, Benioff and Weiss pulled another trick from their pile of pieces on the board. On season five, they brought one of Martin's book moments to life when Melisandre spooked Jon Snow by saying Ygritte's iconic words to him: "You know nothing, Jon Snow."

And so Melisandre repeated a line from way back on the first season, one told to Arya by her first teacher in combat, Syrio Forel: "What do we say to the God of Death?"

"Not today," Arya replied, just as she had on season one.

Arya and Syrio's "not today" lines don't happen in Martin's books. HBO

Both of these moments shouldn't be called foreshadowing, because Benioff and Weiss had no idea Arya would kill the Night King when they wrote them into seasons one and three. Instead, they're examples of retcons.

A retcon, or "retroactive continuity," is when writers introduce a new piece of information that gives past events new context. The way Benioff and Weiss retconned Arya's storyline to fit in with the Night King's death was successful in a way many retcons often aren't.

In Martin's books, Arya is indeed steeped in death and destruction. Above most of the other Stark children, Arya is the one who experiences the brutalities of war and torture and death firsthand while she's traveling in Westeros. And she does indeed go to Braavos and begin her training in the arts of effective assassination.

Pivoting her established narrative of death and vengeance into a mini arc that led her to kill the Night King was a crafty move by Benioff and Weiss when the walls of the adaptation process were closing in on them.

By choosing Arya's 'not today' scene as the key callback, Benioff and Weiss were harking back to the core of their adaptation process

D.B. Weiss and Benioff at a "Game of Thrones" premiere. Jamie McCarthy / Getty Images

In 2012, after the second season aired, HBO published a book called "Inside HBO's Game of Thrones," written by Bryan Cogman, a cowriter and executive producer. He interviewed Benioff and Weiss for an opening section of the book and asked them about which scenes or lines of dialogue they were "most proud of writing."

"The bit where Syrio tells Arya about his beliefs: 'There is only one god. His name is Death. And there is only one thing to say to Death. Not today,'" Benioff replied.

Martin's books include many teaching moments between Arya and Syrio, but the scene as it appears on season one of "Game of Thrones" was a mix of Martin's characterization of Syrio and newly invented dialogue.

Benioff said the scene "perfectly showcases the collaborative process on 'Game of Thrones.'"

He added: "George, of course, invented both Arya and Syrio. We originally didn't plan to have this particular Arya-Syrio scene in the episode, but [Episode 106 cowriter] Jane Espenson convinced us it was a good idea. Dan took Jane's original scene and reconfigured it. I came up with those lines about Death."

The moment when Arya first heard the words "not today." HBO

Syrio gave this lesson to Arya the day after Jaime Lannister attacked Ned Stark and his men in the streets of King's Landing. She's shaken and scared, and unable to focus on her sword fighting. She fights back tears as Syrio teaches her that bravery and mindfulness, particularly in the face of terror, is the only way to survive.

Benioff and Weiss choosing this scene as the groundwork for the death of the Night King makes sense because it was a distillation of their entire experience adapting Martin's work. They had chosen to adapt an intricate, dense, foreshadow-laden book series that wasn't finished yet. Part of that adaptation process was always going to include a cutting down of characters and scenes and narrative development in order to tell the complicated story to a television audience.

In the foreword for "Inside HBO's Game of Thrones," Martin said his series was "absolutely unfilmable, of course." But Benioff and Weiss wanted to try, and HBO gave them as much monetary support as possible over the years to make the unthinkable happen.

"The two madmen were undeterred," Martin said. "They loved the story and were convinced that they could bring it to the screen. So I let them try. Best call I ever made."

The final season of 'Game of Thrones' was always doomed to divisiveness

Melisandre, Sandor Clegane, and Arya on "The Long Night." HBO

A major part of the backlash to "The Long Night" stems from a faction of the fandom that has been heavily invested in Martin's book series for at least 10 years. The chosen ending of the "Great War," as characters on the show have called it, against the White Walkers was baffling to people who have pored over Martin's texts and followed the breadcrumbs of prophecy pointing to Jon Snow or Daenerys Targaryen.

Benioff and Weiss wrote "The Long Night," which contained very little dialogue and was much more of an action- and horror-driven episode. But it also closed the door on many, many storylines that began in Martin's books.

Melisandre's belief in a prophesied hero, called Azor Ahai or The Prince That Was Promised, turned out to be less of a single savior and more of a team effort. Arya alone doesn't fit all the established markings of the hero, and it's because she's unlikely to be the one who deals the death blow to the White Walkers in Martin's books.

Daenerys Targaryen and Jon Snow each played a role in the fight against the Night King. Helen Sloan/HBO

Which is precisely the problem. We don't know where Martin was heading with the prophecy, because he hasn't finished his story yet.

For two earlier-season twists that hadn't happened yet in the books, the burning of Shireen Baratheon and Hodor's death, Benioff and Weiss spoke openly about how Martin had told them these events were planned. But for the final season, the "Game of Thrones" showrunners are keeping their lips sealed about which parts of the ending were transcripted by Martin and which they crafted on their own.

"So one thing we've talked to George about is that we're not going to tell people what the differences are," Benioff told Entertainment Weekly ahead of the final season. "So when those books come out people can experience them fresh."

This means fans are left to devour one another, debating the narrative arcs on "Game of Thrones" and whether they're true to Martin's story that we watched play out for the first several seasons when the show was closely adapting his novels.

The problem with retcons is that they feel like a cheaper version of true foreshadowing and planned storytelling

This all brings us to Arya and the Night King.

Benioff and Weiss were cornered into finding solutions for character arcs once the show overtook Martin's books, a scenario nobody wanted to happen nor ever thought would — until it did.

Fans searching for answers among the shattered pile of glass that was once the White Walkers are finding only misery. Benioff and Weiss looked at the pieces they had on the board and made their choice to "avoid the expected." Fans who had expectations rooted in decades of theory-crafting and analysis of Martin's work feel as if all those layers of true foreshadowing were tossed out the window in favor of retconning new meaning into Arya's story.

Arya's skills with weapons have been embedded in the show since the start. HBO

Arya Stark, the once servant of Death and student of killers, defeating the personification of Death is poetic. Of all the players left in the game, she had the most skill and training for a one-on-one fight against the inhuman Night King.

Benioff and Weiss telegraphed in her ability for a silent attack both during the episode itself with the library scene, and earlier on the season when she snuck up on Jon Snow in the godswood. They also repeated her dagger-flip move from the training session she had with Brienne on season seven.

Regardless of how incredible this moment is for Arya's arc and for the story as a whole, fans, especially book readers, were inevitably going to tear into the choice, because Benioff and Weiss admitted it wasn't part of the foundations of the story in the beginning.

The Night King is dead, and many fan theories went down with him. HBO

Retcons, even ones pulled off as successfully as Arya's "not today" moment, will always feel like a cheaper version of true foreshadowing and planned storytelling. Especially for a series with record-breaking viewership, budget, and global excitement. But it was impossible for Benioff and Weiss to ever truly foreshadow an ending they didn't know at the time.

This is not how "Game of Thrones" was supposed to end. It's not what Martin wanted, HBO wanted, Benioff and Weiss wanted, or fans wanted. People thought they'd read the final book of "A Song of Ice and Fire" and then tune in to see the awe and emotion and spectacle brought to life in a TV adaptation.

But that's not what we're getting and the reckoning of this reality is only just beginning.

For more "Game of Thrones" insights and analysis of all the best moments in the series, preorder the "The Unofficial Guide to 'Game of Thrones'" now.