Dogs that have been rescued, more often than not, return the favor, offering their human companions unconditional loyalty. In the case of the pooch at the center of “Sgt. Stubby: An American Hero,” the titular canine doesn’t just save its owner’s life, but a whole Army regiment.

Set during World War I, the animated feature is based on the true story of a mutt that wandered off the streets of New Haven, Conn., and into the care of Robert Conroy (voice of Logan Lerman), an enlisted man who was training with the 102nd Infantry Regiment. At first, Conroy’s superiors aren’t too keen on Stubby, as Conroy calls his new, short-tailed friend. But after the soldier trains the dog to salute, Stubby becomes an official mascot.

When the regiment ships out to France, Stubby proves to be much more than that, sniffing out wounded soldiers in the field and warning American troops and French villagers of an impending mustard-gas attack.

Filmmaker Richard Lanni, who produced TV documentaries about World War II, was preparing a World War I project when he discovered the story of Stubby. For his first animated feature, Lanni and a team of artists have created a main character whose compact, athletic physique and wide, expressive eyes make for an endearing version of man’s best friend.

Unfortunately, most of the human characters are comparatively bland. Gaston, a French soldier voiced by Gerard Depardieu, is something of an exception: a vivid if standard-issue jolly giant. Conroy, for his part, suffers from a particularly flat character design.

Given its pedigree, “Sgt. Stubby” takes fewer liberties than some fact-based war movies. Bolstered by an irresistible protagonist, the script by Lanni and Mike Stokey makes up for shortcomings in animation. It may not be “Isle of Dogs,” but this tale of canine courage is just appealing enough that many civilians with a soft spot for a stray will not hesitate to enlist.