The third—and presumably final—installment of the animated franchise that began as long ago as 2010 and continued into a 2014 sequel (as well as a TV series) retains much of the charm and excitement of the first two films, and works hard, if not always successfully, to replicate their sense of wonder and humor. One can carp at a few of the choices writer-director Dean DeBlois makes, but overall “How to Train Your Dragon: The Hidden World” is a satisfying conclusion to one of the better animated series of recent years.

The film opens with young hero Hiccup (voiced by Jay Baruchel) having assumed the position of chief in Berk, now a happy place where humans and dragons live together in harmony (his departed father Stoick, voiced by Gerard Butler, appears occasionally in flashback). He and his crew of stalwart supporters, led by his obvious romantic interest Astrid (America Ferrera), are engaged in an assault on an enclave of dragon poachers in order to free the captive beasties and take them back to Berk where they’ll be safe.

That’s the first of the big set-pieces in the movie, and the weakest of them, being staged rather clumsily and shot in very dark hues. But things quickly improve visually and the later major visual sequences are handled with greater aplomb.

These are connected with the script’s overriding story threads. One is the intervention of master dragon hunter Grimmel (F. Murray Abraham), who takes aim at Hiccup’s pet-partner Toothless, presumed to be the last of the male Night Furies—a species the villain is devoted to wiping out. His scheme to do that involves introducing Toothless to a female Light Fury that he’s already captured—thereby encouraging a romance that will divert Toothless from his bromance with Hiccup and induce both of them to make mistakes.

The dragon dalliance allows the animators to show off in a long courtship routine, some of it on land (where Toothless, with some silly Cyrano-like help from Hiccup, does a ridiculous dance) and some in the air, where the two dragons soar in tandem. Juxtaposed with the sequence is the periodic banter between Hiccup and Astrid, who are no less destined to be together.

The other memorable moment comes when Hiccup finally comes upon the secret valley where all the species of dragons live together in what appears to be absolute contentment and security—a place he wants to move Berk to. (How all the critters survive in such a closed environment in a question never posed, but set it aside.) The images of the place are absolutely resplendent, comparable to the shimmering, kaleidoscopic undersea world conjured up in “Aquaman.”

There’s one more big action sequence—the inevitable face-off between Hiccup and Grimmel—but it reverts to the more prosaic approach of the opening free-the-dragons sequence. It’s perfectly fine in its own way, but comes across as obligatory rather than inspired. Happily it’s followed by a conclusion that, while sentimental, serves to end the series on a note that shows the depth of the bond that has developed between boy and beast and the power of love. And it’s followed by an irresistible coda set in the not-too-distant future.

There are some elements to “Hidden World” that fall a mite short. While most of the secondary characters—including Hiccup’s mother Valka (Cate Blanchett), Eret (Kit Harrington), Gobber (Craig Ferguson), and even the little hobgobblers, the movie’s version of the minions—make solid contributions—others are given entirely too much screen time. Snotlout (Jonah Hill) is one of them, but even he pales beside the goofy twins Ruffnut (Kristen Wiig) and Tuffnut (Justin Rupple). All are meant to be irritating—there are even jokes about it; but the jibes prove all too accurate. The emphasis on them also leads to a slightly overlong running-time; editor John Carr might have considered a bit of trimming.

Even those characters’ all-too-frequent intrusions, however, can’t seriously damage the movie’s quality. From both a narrative and a visual perspective, “How to Train Your Dragon: The Hidden World” is a patent winner.