With “Rango,” the only thing more astonishing than its subversive sense of humor and general anarchy is the fact that a studio is putting it in wide release. It’s a cartoon about talking animals, but I don’t know if kids will like it. I’m not even sure it’s intended for them. Some of the jokes are surprisingly grown-up. The story has direct references to “Chinatown,” “Blazing Saddles,” “Star Wars,” “Apocalypse Now,” and spaghetti Westerns. The humor is slapstick one minute, hallucinatory the next. The characters are deliberately un-cute in appearance, with great attention paid to the grimy details of their matted fur, unsightly scales, and physical imperfections. The whole thing feels like the Coen brothers made a Tex Avery cartoon set in the Old West, ran it through a Pixar filter, and then dipped it in LSD.

Rango, voiced by Johnny Depp, is a pet chameleon suffering from an existential crisis. A natural-born actor, he amuses himself by carrying out playlets with the props in his terrarium (headless Barbie doll, wind-up fish toy), until one day fate delivers him out into the world — the Mojave Desert, specifically. Advised by a wise, elderly armadillo (Alfred Molina), our lizard friend goes on a spiritual quest that takes him to the tiny town of Dirt, a saloon-and-mercantile outpost populated by desert animals.

It’s here that the chameleon realizes the opportunity to give himself an identity — not to start his life over, really, but to start it for the first time. (“Rango” is the name he chooses for himself, after the town of Durango.) He tells tall tales of his past adventures, dazzling the cactus-juice-besotted crowd at the saloon. He speaks quickly and engagingly, like George Clooney in “O Brother, Where Art Thou?”: erudite, but folksy. The residents of Dirt, who are experiencing a severe drought and use water as currency, love him, though the requisite brassy female, Beans (Isla Fisher), is skeptical. Soon Rango is the new sheriff.

Like all the towns in the formulaic Westerns of yesteryear, Dirt is regularly troubled by bandits. In this case, the residents live in fear of a hawk (or perhaps hawks in general) and a rattlesnake named Jake (Bill Nighy). The town is controlled by the mayor, a wheelchair-bound turtle with the voice of Ned Beatty who is clearly patterned after John Huston in “Chinatown.” There is also the matter of the moles, who can dig tunnels and perhaps steal what precious water is left in the Bank of Dirt. Oh, and the story is observed and commented on by a quartet of mariachi owls.

This is the first animated film directed by Gore Verbinski, whose track record includes everything from idiosyncratic, under-appreciated gems like “The Mexican” and “The Weather Man” to blockbusters like “The Ring” and the “Pirates of the Caribbean” trilogy. “Rango,” with its cheerfully off-the-wall style and twisted sense of humor, is closer to the first category. (Verbinski shares story credit with James Ward Byrkit and John Logan; Logan, who wrote “The Aviator” and “The Last Samurai,” is credited with the screenplay.) Energetically loony, the film is full of peculiar throwaway details, like the fact that Beans’ father died when he got drunk and fell down a mine shaft, or the grizzled Dirt resident who you can tell once got shot in the eye with an arrow because the arrow is still protruding from his head. There’s a vivid assortment of colorful characters populating the town, all animated to perfection and voiced with rootin’-tootin’ enthusiasm by actors both famous and not.

If the film has a flaw, it’s the same one a lot of smart-aleck animated comedies have: not much heart. Rango and company are fun, sure, but that’s all there is to them. Then again, who says a feature-length cartoon has to be emotionally rewarding? Maybe we’ve been spoiled by a certain other toon factory’s knack for touching our hearts and have come to take that miracle for granted.

“Rango” is memorable, to say the least. I’m not entirely sure what to make of it, except to say that it’s unusual, hilarious, and endearingly weird. I have no idea what age level it’s appropriate for, and I’m glad I don’t have to worry about it. You get the impression Verbinski and his cohorts did what they thought would be fun, without regard for how it would be marketed. I’d be surprised if there’s an animated film this year that proves to be more daring and inventive than this one.

A- (1 hr., 47 min.; PG, a couple 'hells,' some crude humor, a little innuendo that will go over kids' heads.)