This is the way “The Hobbit” ends: not with a whimper, but with an epic battle royale. True to its subtitle, “The Battle of the Five Armies” (revised from the initially more pacific “There and Back Again”), the final installment of Peter Jackson’s distended “Lord of the Rings” prequel offers more barbarians at the gate than you can shake an Elven sword at, each vying for control of mountainous Erebor. The result is at once the trilogy’s most engrossing episode, its most expeditious (at a comparatively lean 144 minutes) and also its darkest — both visually and in terms of the forces that stir in the hearts of men, dwarves and orcs alike. Only fans need apply, but judging from past precedent, there are more than enough of them to ensure that “Battle” walks off with the dragon’s share of the upcoming holiday-season box office.

“Third time pays for all,” the hobbit Bilbo Baggins (Martin Freeman) is fond of saying in Tolkien’s novel, and much the same might be said of the “Hobbit” films themselves. After getting things off to a sluggish start with 2012’s “An Unexpected Journey” (complete with an interminable dinner-party sequence that was like a Middle-earth “Exterminating Angel”), Jackson quickened the pace considerably for last year’s “The Desolation of Smaug,” which built to a breathless, “Empire Strikes Back”-style cliffhanger, only with fire substituted for ice. Having finally arrived at their usurped ancestral kingdom, our band of intrepid dwarf warriors (plus one weary hobbit) found themselves face-to-face with the gold-hoarding dragon Smaug. Crankily stirred from his slumber, the great beast in turn winged off into the night to obliterate the (mostly) innocent human denizens of nearby Lake-town, punishment for helping Bilbo and company to reach his door.

“The Battle of the Five Armies” picks up exactly there, with Smaug swooping down in a blaze of fiery vengeance, while the panicked Lake-town locals disperse in various displays of cowardice and courage. It’s an exciting sequence, animated by a real sense of danger and by the nightmare figure of Smaug himself (one of the movie’s most special effects, again voiced by Benedict Cumberbatch), who exudes a kind of grotesque majesty even as he flaps his great wings for the last time and falls thunderously to his death. But the joy brought by the vanquishing of the dragon proves short-lived, as something far more sinister — namely, politics — soon rears its hydra-like head.

As has held true for promised lands of all sorts since time immemorial (and continues to do so), Erebor in the post-Smaug era becomes a contentious destination for various tribes who hold some real or imagined claim to the mountain and its vast store of riches, including large contingents of Iron Hills dwarves (under the command of Billy Connolly’s Gen. Dain Ironfoot), Woodland elves (led by Lee Pace’s Thranduil) and the displaced masses of Lake-town itself, reluctantly corralled by the dragon-slaying boat captain Bard (Luke Evans). It doesn’t help matters that the dwarf prince Thorin Oakenshield (Richard Armitage), presumptive heir to Erebor’s throne, is not long inside these hallowed walls when he succumbs to a familiar Tolkeinian malady — a lust for gold and jewels that renders its victims void of reason or empathy. And if “The Battle of the Five Armies” feels psychologically weightier than the previous “Hobbit” films, that’s largely a credit to Armitage, who plays Thorin with the paranoid despotic rage of a Shakespearean king, his heavy-lidded eyes ablaze with a private madness.

Even fair Bilbo, so skilled in negotiating with ruthless opponents like Gollum and Smaug, finds himself unable to speak truth to power, and thus spends much of “The Battle of the Five Armies” watching from the sidelines, a supporting character in his own eponymous narrative. But then, the battle’s the thing this time, and when Jackson gets to the nearly hourlong setpiece (commencing around the 70-minute mark), he stages it grandly even by his own Wagnerian standards. From all corners of the land — and the frame — they come: dwarves, elves, men and assorted forest creatures, initially at cross-purposes, but soon enough united against not one but two flanks of hideous, bulbous orcs on a mission from their god, the dark lord Sauron, who’s been hankering for a comeback.

This sort of scene, drawing on every available trick in the CGI paintbox, has become such a reliable staple of Jackson’s work (to say nothing of the many lesser films of the past decade that have worn his influence on their sleeves) as to risk seeming almost ordinary. But Jackson, who’s surely aware of this conundrum, invests his five-army rumble with such a visceral feeling for landscape and physical action, a sure eye for elaborate battlefield choreography and, above all, a sense of purpose, that he leaves most of the competition — including some of his own previous battle sequences — seeming like so much digital white noise. Like George Lucas before him, Jackson has unmistakably brushed up on his Kurosawa, and there is at least one image here — of elf warriors leaping over the backs of dwarves and into a head-on orc charge — that could pass as an outtake from “Ran.” Better still: a mano a mano dwarf-vs.-orc duel atop a frozen waterfall that is, shot for shot, one of Jackson’s very best things.

Intermittently, “The Battle of the Five Armies” takes time out to catch us up on the whereabouts of old Gandalf (Ian McKellen, with his usual hammy gusto), the star-crossed interspecies romance of Amazonian elf Tauriel (Evangeline Lilly) and lovestruck dwarf Kili (Aidan Turner), plus flashy cameos for the ethereal Galadriel (Cate Blanchett) and the white wizard Saruman (Christopher Lee, still spry and swashbuckling in his early 90s). On balance, though, this is the least episodic and digressive of the “Hobbit” films, and the one that shows the least evidence of the elaborate patchwork Jackson and his co-screenwriters have done (to disparate bits of Tolkein’s writing plus no small amount of their own invention) in order to transform the slender “Hobbit” narrative into something that might rival “Lord of the Rings” for sheer breadth and depth.

While that effort has ultimately proved only partly successful, it’s easier now to see the entire “Hobbit” project as a labor of love on Jackson’s part, rather than a descent into crass box-office opportunism. Where the first two films often felt like a marking of time by a director intent on fattening his own Smaug-like coffers, “The Battle of the Five Armies” contains a series of emotional payoffs and bridges to the “Lord of the Rings” films that work as well as they do for having been carefully seeded by Jackson in the previous episodes. And if none of the “Hobbit” films resonate with “Rings'” mythic grandeur, it’s hard not to marvel at Jackson’s facility with these characters and this world, which he seems to know as well as John Ford knew his Monument Valley, and to which he here bids an elegiac adieu. Indeed, it is not only Bilbo but Jackson too who returns to the safety of his Hobbit hole, weary and winded, with a quizzical grimace on his face that seems to say: “Where do I go from here?”

Set in a bleak midwinter, with nary a patch of Shire green to be seen until the closing frames, “Battle” sports the most austere and forbidding look of the “Hobbit” films (courtesy of series lenser Andrew Lesnie), entirely absent the overly bright, backlot feel that pervaded “An Unexpected Journey” and parts of “Smaug.” Howard Shore contributes another dynamically ranging (and ever present) score, from gentle Celtic melodies to speaker-rattling basso profondo bombast. Other tech contributions, repping at least five armies’ worth of set designers, costumers, armorers and VFX artists, once again give us the best that Hollywood (and New Zealand tax incentive) dollars can buy.