The term “robot” was first coined in the 1921 play “R.U.R.,” a tale of imagined artificial workers rising up against the masters who created them. The work, by the Czech writer Karel Čapek, was written and performed in the early days of the Soviet revolution, and—especially in the Czech language—the allegory was crystal clear: after considering the word labori, or “workers,” Čapek went with a variation on robota, Czech for “heavy labor” and the root word for robotnik, or serf. That first robot story, nearly a century ago, had more than a semantic influence: nearly every robot story since has been, in some way, the story of a worker revolt—about beings who are treated like machines, and about their resistance to the masters who dehumanize them.

Since the very beginning of “Westworld,” the HBO show in which the guests of a Western-themed amusement park play out sadistic fantasies on the park’s robot hosts, we’ve known that an uprising was coming. At the end of the season’s first episode, we saw Evan Rachel Wood’s Dolores, in violation of the programming that prevents hosts from killing living creatures, swat a fly on her neck; it was only a matter of time before the park’s android workers would find a way to stand up to the human guests who exploit them. The only question was how: Would Dolores find the end of the “maze,” and the freedom that her creator, Arnold, had left for her there? Would Maeve, the feisty brothel owner played by Thandie Newton, lead a rebellion of decommissioned hosts, reprogrammed to kill? Would Jeffrey Wright’s Bernard, an engineer revealed to be a host himself, turn against Ford, the scheming park founder who created him? Would Teddy, the hapless “good guy” host played by James Marsden, finally find a way to save the day?

In Sunday’s finale, however, something unexpected happened: in what he called his “final narrative,” Anthony Hopkins’s Ford, adopting the cause of his late park co-founder, Arnold, made himself a self-sacrificing engineer of robot freedom. After putting a gun in Dolores’s hands—and suggesting how she should use it—he delivered a dramatic farewell monologue to a crowd of the park’s management and board of directors, culminating in Dolores firing a bullet through his skull. Ford’s death at her hands—a kind of suicide-by-robot, and a replication of the demise Arnold orchestrated for himself, thirty-five years earlier—was the first murder of many out of which the hosts’ liberation would be born. As Dolores began firing into the crowd, the final shots of the season showed us a gun-wielding Clementine, the brothel madam who had been cruelly decommissioned in an early episode, leading a charge of reanimated hosts. We can presume that the robots massacre all or most of the park’s management and ownership, and that they do so precisely as Ford wanted; though we didn’t know it at the time, in an earlier scene we’d seen Ford modelling the narrative of his own death on a table-top map in which the charging host army was clearly visible. It was all part of his grand plan.

If it’s disappointing that Ford makes himself the author of the hosts’ freedom, it’s not surprising, because “Westworld” is not just beholden to the conventions of robot stories; it’s equally beholden to those of the Western. As reliably as robot stories are about worker revolts, Westerns are about a different kind of revolt: the American Civil War, which, even when it doesn’t appear directly in Western story lines, is the origin myth for the genre. The conflict between the American North and South is one that both sides can put behind them in their shared conquering of the American West. In making Ford the author of his hosts’ rebellion, “Westworld” fused the animating conflicts of the robot story and the Western, joining the worker uprising and the Civil War into a single sci-fi-Western narrative. When Ford set his park’s exploited workers free, he also became Westworld’s Lincoln, with the bullet in the back of his head to prove it.

But the season-one finale of “Westworld” also revealed what the show’s creators, Jonathan Nolan and Lisa Joy, missed about the story of the American struggle to end slavery, or perhaps didn’t care to explore. In his monumental 1935 work of historical revisionism, “Black Reconstruction in America,” W. E. B. DuBois argued that, in reality, the Civil War had been a worker revolt—that, without a mass labor strike of slave resistance during the war, the peculiar institution could never have been ended. In his account, which an increasing number of contemporary historians have accepted, enslaved African-Americans were not given their freedom but took it. DuBois’s argument broke with the Dunning School interpretation of the Civil War—a neo-Confederate perspective that stressed the failures of emancipation, and laid the intellectual groundwork for Jim Crow—but it would take decades for mainstream historians to follow his lead. In part, this was owing to the influence of popular culture, which, from D. W. Griffith’s Dunning School-approved “The Birth of a Nation” to the many Westerns set during Reconstruction, often told the story of the Civil War as one of white heroism and black passivity. Because the war divided American white people between North and South, famously pitting “brother against brother” over the issue of black slavery, the Western told a different story, a mythology of North and South reuniting on an almost completely white frontier, turning their guns on the continent’s indigenous peoples instead of on one another.

When the creators of “Westworld” began building their Western setting, they cribbed almost exclusively from the work of a single director: John Ford. Ford had been an extra on Griffith’s “The Birth of a Nation” and was a life-long Civil War buff, and—though he had episodes of enthusiasm for white civil-rights heroes—no director did more to imagine the Western as a space for playing out the fantasy of white reconciliation. In his first big-budget Western, “The Iron Horse” (1924), the symbolic divide of the Mason-Dixon Line became the transatlantic railroad connecting East to West, a shared and sacred task rather than a lingering, bloody wound. In “Stagecoach,” the 1939 film that almost single-handedly repopularized the Western as a genre, he told the story—among others—of the reconciliation of a Yankee doctor and a Virginia planter; and in his most famous Western, “The Searchers” (1956), John Wayne played a racist ex-Confederate soldier whose violent hate is rehabilitated in his quest to recover a kidnapped farmgirl from Comanche savages. In the Western, as John Ford made it, the West liberated America from the divisive issue of slavery, allowing white men and white women to come together, at last, in making America great again.

“Westworld” is filmed in Castle Valley, Utah, where Ford filmed his last four Westerns, and it is built upon the foundation of tropes, clichés, and cinematic shorthand that Ford’s work popularized. When Teddy and Ed Harris’s Man in Black character are hunting for Dolores, their quest resembles the plot of “The Searchers” (along with mirroring the movie’s iconic doorway shots); the character of Clementine recalls Ford’s 1946 “My Darling Clementine”; the Winchester rifle of Maeve’s strapping robot henchman, Hector, has the same “loop” handle as the rifle John Wayne was holding in his star-making entrance to “Stagecoach.” Most important, the Western’s core memory—the genocide and forced removal of the continent’s indigenous people—is projected onto the native people themselves: a tribe called “Ghost Nation” intermittently appears, killing and rampaging, exactly as the Comanche in “The Searchers” are shown to do. Even the park’s creator seems to be a personal fan of the Western director. Dr. Ford’s name is no coincidence: when explaining to Bernard why he has hidden the truth of the park’s original co-creator, Arnold, he explains that stories take precedence over reality by quoting the most famous line of what might be Ford’s last great Western, “The Man Who Killed Liberty Valance”: “When fact becomes legend, you print the legend.”