“The Renaissance didn’t happen here,” the voice-over declares, in the opening minutes of Alexei German’s Hard to Be a God. In this final film of his career—now receiving a belated American release at Anthology Film Archives in New York—the late Russian filmmaker immerses us, without respite, for nearly three hours, in his reimagined Middle Ages. I don’t think any film has ever depicted a world so awful with such conviction.

Hard to Be a God was apparently six years in the shooting and another six in post-production. German did not actually quite manage to finish that before he died in 2013; his wife and his son, also a director, did the last of the sound mixing. But the wonder about this exhausting, astonishing film is not that it took so long to make, it’s that it got made at all.

It is, ostensibly, a work of science fiction, adapted from the novel of the same name by Arkady and Boris Strugatsky (whose books were also the sometimes tenuous bases for Andrei Tarkovsky’s Stalker and Alexander Sokurov’s Days of Eclipse, among many other Russian films). A group of scientists travel from a futuristic Earth to Arkanar, a planet much like Earth and inhabited by humans, but which is “about eight hundred years behind” in its history, still trapped in the Dark Ages; the scientists are forbidden from interfering in Arkanar’s historical development and, especially, from killing.

In fact, nothing of the future-Earth or any advanced technology is ever seen. German uses the sci-fi setup simply to unmoor this Arkanaran rendition of the Middle Ages from any recognizable history, and to make it much, much worse. The literate and intellectually curious—or “wiseguys,” as they are called—are hunted down and executed as heretics. Throughout the film, we see them hanging from gallows, their bodies decorated with tar and sequins, or roped two-by-two into a kind of monstrous, force-marched caterpillar, or, in one case, simply drowned in a latrine.

The film’s plot, to the extent that one can be made out through the gloom and filth, is the slow unraveling of the main character, Don Rumata, played by Leonid Yarmolnik, who is one of the visiting Earth scientists, though he no longer appears to do any research. Ensconced as a powerful local lord (and rumored to be the illegitimate son of a god), he attempts to resist the ongoing anti-rationalist pogroms and is drawn into a murky war between two vicious, barely distinguishable factions, the Grays and the Blacks. Rumata eventually manages to rescue one of the most learned Arkanarans. The crazed, half-naked “wiseguy” remarks that a man’s skin is full of holes; it takes a moment to register that this gibberish is actually true, and another to realize that it is for exactly such harmless knowledge that he has been tormented. But as the conflict deepens, friends and members of Rumata’s household are slaughtered, his attempts to wheedle and bluster fail, and finally, after his mistress is killed, he gives in, breaks his vow, and fights.

German works in crisp black and white with long, incredibly elaborate tracking shots—as hypnotic and as beautifully choreographed as anything in Tarkovsky or Bela Tarr, but chaotic, even antic in a way theirs never are. The camera peers around corners, through windows, down darkened hallways; people lurch in front, blocking its view or suddenly making eye contact with it, demanding to be seen. Spears threaten bare buttocks, corpses are looted, mocked, kicked aside, faces are smeared with unidentifiable muck, the rain pours down. The screen is alive with textures: of spoiling meat, dirty feet, sodden leather, the glaring white of a clean fur coat on a nobleman. At times we seem to be caught up in some madcap pageant of degradation that started long before the camera was turned on, and will continue long after the reel runs out. But then there will be a moment of quiet, or sudden beauty: in the midst of an especially elaborate indoor journey, Rumata opens a doorway and pauses before he steps into the darkness—and an owl flies out and lands on his shoulder.

Hard to Be a God is the only one of German’s films that does not directly address Soviet history, though it is not difficult to imagine a twentieth-century inspiration for its atmosphere of feverish debasement. Anthology is also showing the best of his previous work, and in them one can see him apply his merciless style to more immediate matters. Khrustalyov, My Car! (1998) can almost serve as a more cosmopolitan companion piece to his new film (though I wouldn’t advise a double bill). Set mainly in Moscow in 1953, it follows a successful, privileged Party doctor through the final weeks of Stalin’s rule.

Caught in the flailings of the so-called “Doctors’ plot” (in which a number of mainly Jewish doctors were falsely accused of conspiring to kill various Soviet leaders), this arrogant bully is suddenly thrown from power, imprisoned, degraded, then just as suddenly restored and ushered to the bedside of Stalin himself, in time to hear his dying fart. German uses the same impossibly dense extended takes, and the result is in some ways even more unnerving. The vertiginous changes of fortune, barely intelligible plot–filled with doubles, practical jokes, casual brutality, and elaborate lies–and barely believable history combine into a uniquely madcap, enervating paranoia.

The brilliant My Friend Ivan Lapshin (1984) is lighter, warmer, but at heart no less dark. It comes at its atrocity crabwise, instead of head-on. The title character is a Soviet policeman in 1935 in a dreary, snowbound provincial town. The choice of date is significant: the purges loom, as its Russian audience would have known, but they have not yet struck. Lapshin and many of those around him are still genuinely patriotic and hopeful. They sing Soviet songs and scrounge for firewood, their forms and voices weave in and out—at times you almost seem to be watching a film by a Russian Robert Altman—and they are all thoroughly doomed.

German’s tone is more varied than in his later films, by turns nostalgic, lovestruck, mournful, and terrifying. He switches from sepia to black and white to full, raucous color in a kind of visual soundtrack. The threat of state violence sneaks in unexpectedly: there is an extraordinary raid, led by Lapshin, on a brothel on the outskirts of town. The scene is shot in exhilarating extended takes, the closest German gets here to his relentless late style; and at the end the genial Lapshin summarily executes his suspect, then crawls to a nearby shed to be sick.

Don Rumata spends much of Hard to Be a God looking like he’s about to do the same. Though he wears the same sort of clothes as everyone else, and speaks the same language, the Earthling is a walking anachronism: not just visibly healthier and cleaner than those around him (German has a real flair for grotesque physiognomy), but lively, alert, ironic in a way no one else is. Early in the film he lets loose a wailing jazz solo on a kind of crude clarinet, as one of his servants cowers and plugs his ears.

Rumata expresses himself with a detached, affectionate cruelty, kicking and slapping his inferiors as he passes by, shouting threats, insults, and jokes, at times amused, at times just trying to relieve the pressure of his constant, useless disgust. In one of the film’s biggest, darkest jokes, he delivers a long speech about the pointlessness of trying to help any of those around him, since whatever he does will only make things worse. He then frees a nearby slave, removing the wooden stockade from around his neck; the emaciated man takes about three steps and drops dead—and Rumata turns to the camera with an incredulous grin, perhaps the only real smile in the whole movie.

His eventual recourse to violent revenge might, in more conventional hands, have been portrayed as heroic, or at least exciting. Rumata vows to “kill everyone here,” and takes on what seems like dozens of enemies with just a sword. But this climactic battle, or massacre (the film was at one point to be called The History of the Arkanar Massacre), is almost entirely elided. Instead, German lingers on the horrific aftermath, following a gleeful child scavenger through the piles of corpses and dismembered limbs. It is the sequence in the film that comes closest to the edge of ludicrousness, yet it is also, in a way, its most exemplary. The nastiness is so intricate, so monumentally revolting, that it inspires a perverse new reverence, or gratitude, for the real world into which you will soon be able to escape.

Hard to Be a God is playing at the Anthology Film Archives in New York through February 8. A program of his earlier films is showing through February 10.