LOS ANGELES — Everyone felt sorry for Kendrick Lamar after the dazzling young rapper was shut out at the Grammy Awards – even Macklemore, the guy who beat him head-to-head in several categories.

Macklemore sent Lamar an apologetic text after winning in the best rap album category.

“You got robbed,” Macklemore wrote in a text to Lamar that he later posted on Instagram. “I wanted you to win. You should have. It’s weird and sucks that I robbed you.”

Lamar is taking a philosophical approach to being shut out at the Grammy Awards.

Lamar, one of Grammys top nominees with seven nods, didn’t win anything, prompting four-time winner Macklemore to send the text of apology.

“It’s well-deserved. He did what he did, man,” Lamar told XXL magazine. “He went out there and hustled and grinded. Everything happens for a reason. The universe comes back around. That’s how it go.”

Lamar made the remarks after a performance of Backstreet Freestyle at rapper Dom Kennedy’s show last Tuesday night in New York.

They come two days after t he Recording Academy’s voters gave Macklemore & Ryan Lewis three trophies in the rap categories, angering some in the hip-hop community. Macklemore and Lewis also won best new artist.

There was an effort by the academy’s rap committee to exclude Macklemore and Lewis from the rap categories, but it was overruled and the Seattle duo won best rap album for The Heist and best rap song and rap performance for Thrift Shop, featuring Wanz – a pop hit that sold more than 7 million copies.

XXL also asked Lamar if he felt the Grammys undervalued hip-hop. Only three rappers – Jay Z, Macklemore and Lewis, and Lamar – performed during the telecast. All three were show highlights for different reasons.

“I definitely feel like they should always have more of the culture up in there, for sure, because we definitely stand out just like any other genre,” Lamar said. “We part of the world. We part of the movement. So I think any awards, including the Grammys, should always push for more hip-hop because it’s music as a whole, it’s not just splitting different regions. Everything moves as far as sound and vibrations, and that’s how it goes. And we are a part of that.’’

Macklemore, whose real name is Ben Haggerty, has made no secret of his opinion in the best rap album category, declaring early on that he felt Lamar’s good kid, m.A.A.d. city should win best rap album over his own record The Heist.

Drake, Jay Z and Kanye West also were nominated in the category, but the hip-hop community seemed to throw its hopes behind Lamar, a 26-year-old Compton native and Dr. Dre protégé who has deep respect from his peers because of his raw talent, verbal abilities and cinematic vision.

Before the Grammys, Haggerty told the Associated Press he hoped Lamar whould win best rap album.

“I think first and foremost we should absolutely be in the rap category,” Haggerty said. “I think we should be nominated. I think we could have one of the best rap albums of this year that we’re talking about in terms of the Grammys. I think in terms of a rap album, I think Kendrick should win it.

I think there’s many other categories that we’re nominated in that I would love to take home a Grammy, but in terms of that one, I feel it should go to Kendrick.”