Cover art for “To Pimp a Butterfly” (Aftermath/Interscope (Top Dawg Entertainment))

Before last weekend’s surprise leak — or, more likely, intentional drop — of his career-defining, genre-realigning latest album, “To Pimp a Butterfly,” Kendrick Lamar was one hip-hop heir apparent among several.

By Sunday night, there was only one: It’s hard to imagine there will be a smarter or more ambitious rap album this year than “Butterfly.” It’s a dizzying deep-dive examination of race, capitalism, religion, relationships, post-Ferguson America, and fame and its discontents. At almost 80 minutes long, it never flags.

The album has made Lamar, who had already released a promising 2012 ­major-label debut, “good kid, m.A.A.d city,” and a gauntlet-throwing verse on Big Sean’s hit “Control,” into the kind of overnight sensation that rarely happens anymore. It has made chart rivals like Macklemore and Iggy Azalea instantly appear even less serious and more obsolete. It even threatened the hegemony of Kanye West, who spent most of Monday tweeting nude pictures of Kim Kardashian in what seemed an unusually clumsy act of deflection.

“Anybody can get” fame, counsels Lamar’s mentor Dr. Dre, who is a guest star on the opening song “Wesley’s Theory” and is godfather to the G-funk threaded through the album. “The hard part is keeping it.”

“Wesley’s Theory,” a retro-minded thesis on the dangers of selling out, contains unshowy features from George Clinton and wunderkind bassist Thundercat and a bedrock sample of Boris Gardiner’s gentle 1973 funk track “Every N----- Is a Star.” It serves as a warning: This is not an album of bangers. Cerebral, doubtful, peevish, full of self-loathing and bordering on brilliant, “Butterfly” is overloaded with samples, symbolism and questionable coffeehouse poetry and is deeply influenced by free jazz, soul, and, most particularly, ’70s-centric sounds such as disco and funk.

Kendrick Lamar (Christian San Jose )

Even its metaphors have a ’70s vibe: The “Roots”-referencing “King Kunta” is a profoundly strange, talk-box-happy funk explosion, one of many tracks detailing Lamar’s journey “Straight from the bottom / . . . From a peasant to a prince to a . . . king.”

“To Pimp a Butterfly” is a loosely knit concept album that charts the rapper’s rise from a ­little-traveled Compton, Calif., kid to a superstar with survivor’s guilt, struggling to resist the material temptations of fame. On the harrowing “u,” Lamar, in the middle of a hotel-room breakdown, grapples with self-loathing (“I never liked you”) and regret of leaving his friends behind.

It’s a fearless and insular set piece, characteristic of an album more interested in looking inward at the thorny intricacies of the black experience than in interpreting that experience for whites. “Butterfly” lacks the sort of obvious banger that might attract mainstream (read: mostly white) fans. It comes closest to the mainstream with “i,” a tepid single built around an Isley Brothers sample that feels halfhearted, like a politician pandering to a constituency he isn’t sure he wants.

“I can truly tell you that there’s nothing but turmoil going on,” Lamar tells the ghost of his idol Tupac Shakur on the 12-minute closer, “Mortal Man.” The track ends with the rapper asking Tupac questions about his life and work, with Tupac’s posthumous replies drawn from a 1994 radio interview. Twenty years on, Tupac seems less like a flesh-and-blood person and more like a symbol of outsider cool co-opted by the mainstream, as Che Guevara was. Lamar leaves no doubt that he, more than anyone else, has earned his place as Tupac’s heir, “your offspring of the legacy you left behind.” The hard part will be keeping it.

Stewart is a freelance writer.