Mr. Lamar is working to purify hip-hop, a genre he hopes to ground in his true experiences of growing up poor, the son of a former gangbanger. He offers a corrective, or at least an alternative, to the opulent fabulism of some mainstream rap. “You know the songs that are out — we all love these songs,” he said. “They sell a lot of singles and make these record labels a lot of money.”

But those “really living” in the streets don’t want to hear boasts about murder and drug dealing, he continued. “They want to get away from that,” Mr. Lamar said. “If it comes across as just a game all the time, the kids are going to think it’s just a game.

“From my perspective, I can only give you the good with the bad,” he said. “It’s bigger than a responsibility, it’s a calling.”

While some may question Kanye West’s conflicted materialism and ego or Drake’s emotional insularity — or, even the outlaw wisdom of Tupac, who cameos posthumously on “To Pimp a Butterfly” as a guardian angel — Mr. Lamar could be viewed as a more digestible rap messenger. In addition to being religious, he rarely drinks or smokes, eschews fancy clothes and jewelry and has reportedly been in a quiet, decade-long relationship with his high school sweetheart. (“I don’t want to put somebody else in the spotlight and make them a celebrity when they don’t want to be a celebrity,” he said.)

Mr. Lamar, who rarely appears on TMZ or MediaTakeout, failed to name a single vice, other than constantly recording music, watching the TV show “Martin” and eating his beloved Fruity Pebbles.

But at the start of Mr. Lamar’s new album, George Clinton intones over a Flying Lotus beat: “Gather your wind, take a deep look inside, are you really who they idolize? To pimp a butterfly.” In repeated spoken word sections, each telling more of the story than the last, Mr. Lamar acknowledges the risk of “misusing your influence” and in song aims criticism at himself as well as the powers that be.