A failed movie is easy to spot; three or four new ones are delivered like dead mackerel to the multiplex each week. But occasionally curious moviegoers will discover an especially rotten specimen of the genus Cinema stinkibus. Entering the theater with low or no expectations, they’ll stumble upon a film of such numbing incompetence that they are forced to realize it’s not just a bad movie but the bad movie — a work of ur-awfulness, counterbrilliance and antigenius.

Your Highness, the new medieval-fantasy farce starring and co-written by Danny McBride, is such a movie. On its face, it’s a mock-chivalric saga: heroic prince Fabious (James Franco) goes on a quest to save his bride, Belladonna (Zooey Deschanel), from the evil wizard Leezar (Justin Theroux) and drags his wastrel brother Thaddeus (McBride) along. In a trice, though, the movie reveals itself as an R-rated delivery system for masturbation and fellatio jokes. Not to mention the donkey-heart-eating, the severed minotaur penis and an offhand reference to baby raping. (The ick factor is fairly high.) If you were to dismiss the movie as dismal, you wouldn’t be far off.

But you wouldn’t have gone far enough, either. Snap derision does injustice to McBride (Eastbound and Down), a comic actor I described as “like, the fourth funniest person in the free world” when he was in The Pineapple Express, and to the director, David Gordon Green, whose debut feature, George Washington, I tagged in 2000 as “the year’s most imaginative American independent film.” His next three features — All the Real Girls (starring Deschanel), Undertow and Snow Angels — were also on the terrific side. Both McBride and Green, as well as co-writer Ben Best and cinematographer Tim Orr, are graduates of the North Carolina School of the Arts (mascot: the Fighting Pickle); they’re not just bohunks who lucked into a few good projects. Besides, the auteur theory teaches that good directors don’t make bad films. So if Your Highness is a dreadful movie, it would seem that Green made it that way on purpose.

That’s why I feel a kind of head-swiveling awe in Your Highness‘s concentration of aimless inanity, in the purity of its devotion to its own louche principles. Like members of some post-Dadaist collective, the filmmakers have dedicated themselves to memorializing every first, wrong impulse that popped into their heads, while ruthlessly excising any vestige of wit or narrative niceties as being too linear, dude.

Another way of rationalizing the film is to call it the ultimate stoner movie — the High in the title says as much — since it contains plenty of weed references. Green’s introduction to Hollywood moviemaking, after his four indie features, was The Pineapple Express, a dope comedy starring Franco and Seth Rogen, with a nice supporting bit by McBride. Your Highness takes one bold step (or stagger) beyond Pineapple: it appears to have been written, filmed and edited by people under the influence of medical marijuana. The movie’s comedy has the embarrassing staleness of gags that seemed sooo funny when you were high but later have the clinical chill of the police tape, played in court, of a drunk taking a sobriety test. That’s the daring sense of catastrophe that the movie flirts with.

Some people connected with Your Highness must not have been in on the meta joke. Theroux lends Leezar a niftily preening malevolence, playing the villain as a hissy-fit amalgam of Freddie Mercury and Mo Rocca. Franco, though turning on his smile by autopilot, pays a lot closer attention to Deschanel than he did to Anne Hathaway on Oscar night. And one of that evening’s winners, Natalie Portman — who shows up midway through as a warrior princess contemptuous of both Thaddeus’ gross behavior and Fabious’ courtly-love airs — has never looked better, and manages not to be disgraced by the proceedings; she will not have her Academy Award revoked. The people in charge of the stars’ hair and teeth did a splendid job, giving Franco’s and McBride’s coiffures just the right comic body and luster.

Too bad all these fine folks didn’t get what McBride and Green were attempting: a deconstruction, in fact a stock-car demolition, of movie competence. I mean, adhering to all those standards of quality, coherence, invention — that’s just what the Man wants you to do. Renouncing the silly rules of film craft established over the past century, they have started from scratch, reinventing the wheel by making it rectangular, then blithely propelling it down a hill. The clattering crash you hear is the sound of Your Highness arriving at a theater near you.