In the iconic opening panels of Alan Moore’s “Watchmen,” from 1986, a man hoses blood off of a sidewalk as pedestrians stroll by. The words of a masked vigilante named Rorschach hover over the images:

This city is afraid of me. I have seen its true face. The streets are extended gutters and the gutters are full of blood and when the drains finally scab over, all the vermin will drown. The accumulated filth of all their sex and murder will foam up about their waists and all the whores and politicians will look up and shout “Save us!” . . . And I’ll look down, and whisper “No.”

From the outset, it’s clear that these aren’t the tidy streets of Metropolis, where Superman valiantly subdues criminals, or even Marvel’s New York, where Spider-Man saves the day while cracking a few jokes. In “Watchmen” and, two decades later, Garth Ennis’s comic-book series “The Boys,” both of which saw TV adaptations this year, Moore and Ennis imagined darker, grittier worlds—and, accordingly, darker, grittier heroes to inhabit them. In a genre built on idealism—on the notion that perfect heroes could model a more perfect earth—Moore and Ennis asked whether the world, with all of its flaws, corruption, and perversion, was even worth saving.

In the world of “Watchmen,” masked vigilantes have been banned and costumed heroes are in the employ of the federal government. Early in the book, Rorschach, our narrator and one of the last remaining vigilantes, begins to suspect a plot to take him and his masked-superhero friends down. As the conspiracy unfolds, he tries to drag some of his peers—the blue god, Doctor Manhattan; the smartest man on earth, Adrian Veidt, a.k.a., Ozymandias; the sharp-tongued Silk Spectre; and the dweeby Nite Owl—into his investigation. Meanwhile, amid scenes of everyday violence, the Cold War brings their world to the precipice of nuclear destruction, as it did our own.

The real threat, though, turns out to be Ozymandias. His scheme is to save the world from nuclear holocaust by manufacturing his own act of destruction, which will force warring nations to coöperate. The other heroes find him just as he’s accomplished this feat—he’s set a gigantic squid creature upon New York City, causing the deaths of millions—and, while Nite Owl, Silk Spectre, and Doctor Manhattan decide to go along with the plan, Rorschach refuses, pronouncing evil as evil. As a result, he is killed by Doctor Manhattan. Meanwhile, news reports suggest that Ozymandias has succeeded—world leaders are making declarations of peace—and the right thing to do, our heroes decide, is to let a massacre and a lie determine the shape of a new world. The two most powerful heroes in the story—the brilliant Ozymandias and the omnipotent Doctor Manhattan, the latter of whom spends most of the comic indifferent to humans—represent would-be saviors who cite a utopian end to justify horrific means. Neither are indicted for what they’ve done or face any sort of punishment. The comic merely ends.

Twenty years later, in “The Boys,” Ennis took the template of “Watchmen”—corrupt world, questionable heroes—and pushed it to an extreme, including offensive language, graphic imagery, and characters that indulged in every imaginable vice. The series depicts an alternate world in which superheroes are commonplace, and even funded by a corporation. Granted with money, resources, and celebrity, these crusaders are addicts, murderers, racists, rapists, homophobes, and more. When our protagonist, a dewy-eyed young man named Hughie, encounters the depravity of one such hero, he joins the Boys, a gang of misfits led by a mysterious man called Butcher. The Boys, who are in some ways an answer to the core question in Moore’s comic (“Who watches the watchmen?”), aim to keep the hero world in check, using blackmail or force when necessary. (It’s usually necessary.) By the comic’s end, though, a savior figure has once again elected to pursue mass destruction. Butcher, Hughie finds out, wants more than judicial oversight of superheroes; he wants to massacre them, with no qualms about collateral damage.

Both “Watchmen” and “The Boys” imagine society at its worst—a world so incurably infected that even the good guys decide that it must be violently purged in order to be salvaged. In characters such as Butcher and Ozymandias, we are meant to see heroes forced by a broken world to embrace savage solutions. In the comics, as well as in the TV adaptation of “The Boys,” on Amazon, these solutions are presented in shades of gray. Although the “Watchmen” comic includes gruesome full-page spreads showing Ozymandias’s massacre, and contextual clues that bespeak the immorality of his actions, it also seems to validate his promise of peace—suggesting, in short, that perhaps his choice was the moral one. The only judgment of Ozymandias comes through Rorschach, who, with his problematic politics and psychological infirmities, is himself a spoof of the righteous-hero trope. It’s left to the reader, finally, to arbitrate the cost of the greater good.

The TV adaptation of “Watchmen,” on HBO, which aired its final episode on Sunday, takes a slightly different approach. The series, a sequel to Moore’s comic, takes place in the same universe, more than thirty years after Ozymandias’s squid attack. The action unfolds in Tulsa, Oklahoma, where a police officer named Angela Abar, dressed as a kick-ass masked nun called Sister Night, faces a group of militant white supremacists, a mysterious genius who’s building a giant clock, and various characters from Moore’s original story. In the series finale—and spoilers follow—multiple characters aim to capture Doctor Manhattan and absorb his powers, hoping to reshape the world to their liking. Though Manhattan is killed, Ozymandias helps prevent one of the plotters—his own ruthless daughter, Lady Trieu—from becoming all-powerful. And yet, despite saving the day, he’s given no reward. Instead, he’s finally held accountable; a local detective hero named Looking Glass and the former Silk Spectre arrest him for his act of mass murder more than three decades ago. At one point, Ozymandias reminds Silk Spectre that she had kept his secret “all this time.” “People change,” she says. “At least some of us do.”

The central achievement of both “Watchmen” and “The Boys” is how they spit on the fantasy of caped crusaders saving the world. In a genre often beholden to a binary of good and evil, they introduced a more shaded framework, in which injustice flows as much from self-appointed saviors as it does from social dysfunction. The “Watchmen” comic made this argument from a distance: its villain, Ozymandias, is allowed to live and thrive while its god-hero, Doctor Manhattan, impassively moves on to his next project. The show, by contrast, is more blunt in its critique; it actively vilifies those who try to decide, unilaterally, how the world should pay for its sins. Like “The Boys,” it reinforces the fundamentally democratic idea that no authority should be unimpeachable. By the end of HBO’s “Watchmen,” one god is dead and another, Angela Abar, may be born—the screen cuts to black before we know for sure. Having followed Abar as our hero for nine episodes, we might imagine her as the counterpoint to Ozymandias and Doctor Manhattan—judicious yet empathetic, the proper savior of a broken world. Moore and Ennis might argue that there’s no such thing.