Former President Barack Obama inducted rapper Shawn “Jay Z” Carter into the Songwriters Hall of Fame Thursday and opened up about the bond that cements his unlikely friendship with the hip-hop legend.

Carter — who is the first hip-hop artist to be inducted into the Hall of Fame — was recognized for his prolific songwriting career and award-winning collaborations.

In pre-taped remarks, Obama said Jay Z should also be considered a "true American original" for charting his own path to success, despite adversity.

“I like to think Mr. Carter and I understand each other,” Obama said. “Nobody who met us as younger men would have expected us to be where we are today.”

“We know what it’s like not to have a father around. We know what it’s like not to come from much, and to know people who didn’t get the same breaks that we did.”

Related: Did Obama Just Reveal the Sex of Beyoncé and Jay Z's Twins?

Carter, who was born and raised in housing projects in Brooklyn, was involved with dealing drugs before turning his life around to become one of the best-selling musicians of all-time. He has won 21 Grammys, sold more than 100 million albums and had 13 records debut at No. 1 on the Billboard charts, according to the Hall of Fame.

In 2003, Carter “retired” from hip-hop but would go on to release several albums over the next decade while expanding business empire. Although Obama praised Carter’s success as a musician, he also said the rapper should be recognized for his efforts to give back to his community and his devotion to his family.

“We try to prop open those doors of opportunity so it’s a little easier for those who come up behind us to come up as well,” he said. “Jay and I are also fools for our daughters, although he’s going to have me beat once those two twins show up.”

“And let’s face it, we both have wives who are significantly more popular than we are,” he quipped.

Carter — who is expecting twins with his wife, pop superstar Beyoncé Knowles — was not present at the ceremony.The Obamas and the Carters developed a high-profile friendship during the early days of the 2008 campaign for the White House.

Related: Beyoncé Shows Off Baby Bump In Stunning Maternity Shoot

At a rally, then-candidate Obama gave a nod to the Brooklyn rapper’s hit “Dirt Off Your Shoulders” by brushing his shoulders when talking about the divisive political rhetoric of the campaign. Beyoncé memorably sang a cover of Etta James' "At Last" for the Obama's first dance as president and first lady, and caused minor controversy when she was caught lip-synching "The Star Spangled Banner" at his second inauguration.

Obama said he sampled lyrics from Carter’s song “My President” in the conclusion of his speech at the 50th anniversary of the March on Selma, and that he once tweeted a reference to Carter’s “My First Song” while he was writing his final State of the Union address.

President Barack Obama is hugged on stage by Jay-Z as Bruce Springsteen looks on at a campaign event at in Columbus, Ohio in 2012. Carolyn Kaster / AP file

Carter has frequently alluded to exchanging texts with Obama in interviews, and gave a nod to the country's first black president in the song "My President," rapping in one verse, "Martin Luther walked so Barack Obama could run/Barack Obama ran so all the children could fly."

Obama returned the admiration in his speech Thursday.

“Like all of you I am a fan, and I’ve been listening to Jay since I was a young and hungry state senator,” Obama said. “I’m pretty sure I’m still the only president to listen to Jay Z’s music in the Oval Office.”

But Obama said above all, he admires Carter for remaining true to himself, and closed the speech by sharing a quote from the rapper that he said inspired him: “I never looked at myself and said that I need to be a certain way to be around a certain sort of people. I’ve always wanted to stay true to myself, and I’ve managed to do that, people have to accept that.”