There’s no question “Appaloosa” is a Western. It’s set in 1882 in the New Mexico Territory, it has tin-star-wearing city marshals getting into gunfights with ornery cusses, it includes some scenes involving problems with Indians — the whole nine yards. But underneath all that, it’s really just a buddy movie, a rough-and-tumble, no-girls-allowed, steak-and-potatoes romp that happens to be set in the Old West. It’s as much Don Quixote and Sancho Panza as it is Butch and Sundance.

The buddies are Virgil Cole (Ed Harris, who also directed) and his sidekick, Everett Hitch (Viggo Mortensen), an inseparable pair of freelance peacekeepers and expert gunmen. At the film’s outset, they are hired by the dusty frontier town of the title to protect it from Randall Bragg (Jeremy Irons), a devious rancher whose band of ne’er-do-wells occasionally murders local citizens, including the previous city marshal. With Cole as the new marshal and Hitch as his deputy, the two set about enforcing law and order.

One of the town’s new ordinances, under Cole’s direction, is that you can’t bring guns inside the city boundaries. He informs a couple of Bragg’s men of this when they show up at the saloon one day.

“That’s the law,” Cole says.

“YOUR law,” replies one of the men, scoffing.

“Same thing,” Cole says. OH SNAP!

Yes, Cole’s word is law, and his actions, while occasionally unorthodox, are effective. His handiness with a gun — and Hitch’s unflinching expertise as his second — means that Bragg’s crew soon gets the message, though a few of them will have to have the message sent to their next of kin. When the city elders complain to Hitch about Cole’s tactics, Hitch reminds them: “You hired him to be Virgil Cole.” And Virgil Cole is exactly what he’s being.

This full-time job of being Virgil Cole is interrupted by the arrival of a comely young widow named Ally French (Renee Zellweger). She rolls into town, immediately takes a liking to Cole, and immediately traps him in domesticity. (Thankfully, the film doesn’t rely on those jokes for very long. A couple references to Cole’s discomfiture over being asked his opinion on curtain patterns, and that’s it.) Ally’s behavior puts the “loose” in “Appaloosa,” though, and Cole’s dealings with her and his dealings with the Bragg gang eventually converge for some of the gunplay and shootouts and showdowns that you pay for in a Western.

The film’s tagline is “Feelings get you killed.” I guess that’s better than the one I thought of: “Girls ruin everything.” The Cole/Hitch dynamic is the story’s central concern, and Harris and Mortensen (who re-teamed after enjoying their experience together in “A History of Violence”) play the taciturn, plain-spoken duo flawlessly. Cole and Hitch have been friends a dozen or so years, and they understand one another without needin’ to use a lot of verbiage. Cole, who enjoys books and wants to be more well-read, sometimes can’t come up with the 10-cent word he’s thinking of, and the ever-faithful Hitch will help him out. Each man is fiercely loyal to the other. You don’t have to worry about anyone breaking up their friendship, least of all Ally French.

“You believe him over me?” she asks Cole when her account of something differs from Hitch’s version.

“That is correct,” Cole replies. And the matter is closed.

Harris, in the director’s chair for the second time (“Pollock” was the first), co-wrote the screenplay with Robert Knott, adapting it from Robert Parker’s novel. Harris has an eye for fun, letting the characters’ dry interactions provide humor without getting too silly, and he’s keen on making the film vastly entertaining in the old-fashioned ways: fun story, fun characters, fun everything. Jeremy Irons’ performance as Randall Bragg recalls two notorious frontiersman of recent vintage, Al Swearengen from HBO’s “Deadwood” and Daniel Plainview from “There Will Be Blood,” but it’s essentially every grizzled bad guy who harassed every small town in every Western.

This high-spirited B-movie aesthetic holds true for about two-thirds of the film, and then things get soggy and listless, with some vague climaxes and lackluster storytelling. The film comes to what seems like its conclusion, only to mosey along for another reel, and you wonder why Harris would fail to uphold the timeless frontier principle of gettin’ while the gettin’ is good. Still, the film made me smile for a solid 90 minutes. Like Hitch, I’d follow Cole just about anywhere.

B (1 hr., 54 min.; R, fleeting partial nudity, moderate violence, three F-words.)