“What’s up, Doc?”

That’s just one of a few running gags that keep afloat the cockamamie, kaleidoscopic, languidly compelling whodunit of “Inherent Vice.” The Doc in question isn’t a wascally wabbit, but Larry “Doc” Sportello, a private eye living in the seedy environs of Gordita Beach, Calif., in 1970. Like his animated counterpart, this Doc (played in a hirsute, thoughtfully spaced-out turn by Joaquin Phoenix) gets out of his share of scrapes in a tale whose characters, structure and tone — a balance between mournfulness and inspired mayhem — often feel as if they were crafted by Raymond Chandler while under contract at Looney Tunes.

Based on the 2009 novel by Thomas Pynchon — long considered unadaptable by even Hollywood’s most resourceful repurposing machinery — “Inherent Vice” roils and simmers with epochal shifts, spiritual cataclysms and eerily prescient observations of present-day realities, from long-brewing mistrust of the police to a burgeoning security state. But as a viewing experience, it’s a remarkably mellow, even soothing experience.

Written and directed by Paul Thomas Anderson, who has made a career of capturing Los Angeles from every angle, era and collective mood swing, “Inherent Vice” unfolds so organically, so gracefully and with such humanistic grace notes that even at its most preposterous, viewers will find themselves nodding along, sharing the buzz the filmmaker has so skillfully created. Even if you don’t normally partake of this manner of cinematic controlled substance — the raunchy sight gags, steady flow of joints and the occasional line of cocaine, the scenes that have a tendency to resolve into tawdry soft-porn cliches — you may find yourself quite enjoying its sun-kissed but also sharply observant contact high.

So what’s it about, you ask? On its surface, “Inherent Vice” follows the dictates of the film noir classics, from “The Big Sleep” and “The Long Goodbye” to “The Big Lebowski,” whose protagonist, the Dude, now looks like Doc Sportello’s aspirant younger brother. As “Inherent Vice” opens, Doc is visited by the requisite femme fatale — in this case his “ex-old lady,” Shasta Fay Hepworth (Katherine Waterston), a lissome beach babe whose Hollywood ambitions have sidetracked her into being the kept woman of a billionaire real estate developer. She needs Doc’s help on a case that will lead to him crossing paths, in no particular order, with Los Angeles’ most rapacious business interests, a proudly civil-rights-abusing police lieutenant, the Aryan Brotherhood, an attorney with expertise in marine law, a coke-snorting dentist, a gaggle of curvaceous, hyper-sexualized women and a sax player for a surf rock band who may or may not have faked his own death and taken up residence in Topanga Canyon.

Fans — or merely interested onlookers — of Pynchon’s work know that it’s famously gnarly, dense and word-happy to an ecstatic extent. Anderson has tamed all that into an impressively legible narrative, whose doglegs and digressions wind up making just enough sense that the audience won’t miss the much more important bigger picture. The woozily wacky superficial hunt that animates “Inherent Vice” is merely the scaffolding on which Pynchon and Anderson explore what really interests them. That’s the interregnum between the idealism of the 1960s and the crass commercialism of the ensuing decades; how anti-materialist ideals and activist politics were subverted and co-opted by the cynical forces of social control and profit-driven enterprise; and, finally, the collision of two paranoid cultures. One is the order-obsessed, cult-wary law enforcement apparatus, and the other is the lumpen-bohemian “hippie scum” whose Golden Age of Woodstock was fast giving way to the venality of Altamont.

Anderson’s last movie, “The Master,” was an enigmatic character piece, largely a two-hander dominated by Phoenix and the late Philip Seymour Hoffman. Here, the filmmaker goes back to his “Boogie Nights” and “Magnolia” roots as casting director extraordinaire, enlisting the best faces in the business to give warmth, humor and pathos to characters whose antic contradictions and off-the-wall pronouncements are nearly always suffused with unmistakable, if unspoken, sorrow. Waterston delivers an impressive breakout performance as the willowy Shasta, whose pull on Doc is palpable (especially in a bravura erotic set piece late in the film). Josh Brolin steals every scene he’s in as the square-jawed, straight-arrow Lt. “Bigfoot” Bjornsen, whose dismay at the downward spiral of American values is almost equal to his horror that part-time acting work on shows like “Adam-12” has dried up. Benicio Del Toro may have a relatively small part as Doc’s attorney, Sauncho Smilax, but he makes the most of every moment, admirably keeping a straight face at every bent, bizarro turn.

Really, there are no small parts in “Inherent Vice,” which co-stars the likes of Eric Roberts, Owen Wilson, Reese Witherspoon, an amusingly be-wigged Maya Rudolph and Martin Short in one of several of the film’s hilariously outrageous sequences. Hilarious, but not without tenderness: While Doc and his fellow travelers toke and toot up, Anderson makes sure to remind the audience that, just off-screen, there are people being oppressed, whether they’re residents of a black neighborhood being razed by developers, mentally ill patients being deinstitutionalized or those pulchritudinous women who are routinely exploited, objectified and victimized by the men running any number of shows. (This somber subtext is reinforced by Jonny Greenwood’s gorgeous acoustic score, which juxtaposes perfectly with songs by the Association and Neil Young that make up a carefully curated soundtrack.)

At times, it’s difficult to discern between the cruel gender politics that “Inherent Vice” is critiquing and that the movie itself is engaging in. But it surely counts that the lone voice of wisdom belongs not to Doc, but to his friend and the film’s narrator, Sortilège, played by the cotton-voiced Joanna Newsom. It’s “Lège” who winds up being the moral center of “Inherent Vice” and who spurs Doc — part shamus, part shaman, part shambolic mess — along on his stoned, sad-eyed travels. And it’s her voice in his head, one senses, that inspires him to perform the film’s climactic act of twisty comeuppance and simple kindness. Turnabout’s fair play in “Inherent Vice,” which is another way of saying that karma may not always be a beach, but it can sometimes be found there.

★ ★ ★ ★

R. At area theaters. Contains pervasive drug use, sexual content, graphic nudity, profanity and some violence. 148 minutes.