Ed Sheeran is thankful for Eminem.

Sheeran was a guest on "The Howard Stern Show" and opened up about how rapping Eminem's "The Marshall Mathers LP" when he was 9 years old helped "cure" his stutter.

Stern explained that Sheeran had surgery to "burn" a birthmark off his face, noting that the doctors "by accident" didn't give Sheeran anesthesia. "And they literally hurt you so bad when they were trying to burn this thing off that it caused you to stutter," Stern said.

Sheeran responded by saying he thinks the procedure affected his nervous system and led to the stutter.

ED SHEERAN BREAKS DOWN ABOUT WIFE'S CANCER DIAGNOSIS AMID ‘THINKING OUT LOUD’ JURY TRIAL

"I was going through all sorts of speech therapy," Sheeran, 32, told Stern last week. "When I was 9, my uncle bought me ‘The Marshall Mathers LP.’ He just said to my dad, 'This guy's the next Bob Dylan.' My dad didn't really clock it, he's just like, 'OK, Edward's going to go and listen to that.'"

Ed Sheeran and Eminem

Ed Sheeran, left, said Eminem, right, helped fix his stutter as a kid. (Getty Images / File)

"And by learning that record and by rapping it back to back, to back, to back, it cured my stutter," the musician said. "And I stopped ... talking like that."

Sheeran – who is a Grammy Award-winning songwriter – has since collaborated with Eminem. The pair worked together on Sheeran's "Remember the Name" and Eminem's "River" and "Those Kinda Nights."

In 2022, Sheeran attended Eminem's Rock and Roll Hall of Fame ceremony and joined him onstage for a performance of "Stan."

"Years later, I've made songs with Eminem now, and we've gotten to know each other quite well," Sheeran told Stern. "And he asked me to play 'Stan' with him at the Rock and Roll Hall of Fame. I remember getting the call to do it ... and I'm shooting 14 music videos back-to-back. It was on my day off from shooting the music videos, and I was like, I can't say no."

Eminem and Ed Sheeran perform on stage

Eminem and Ed Sheeran perform onstage during the Rock and Roll Hall Of Fame induction ceremony in 2022. (Jeff Kravitz / FilmMagic / File)

He continued, "So, I got a plane straight after my music video, flew there, sung and then that night flew back. And it was really worth it."

CLICK HERE TO SIGN UP FOR THE ENTERTAINMENT NEWSLETTER

Sheeran opened up about what the performance meant to him.

"He is quite reclusive and doesn't see or meet that many people," Sheeran began of Eminem. "I felt, the first time I met him, I was super nervous. As soon as he walked in, we started talking about Marvel Comics."

Ed Sheeran smiling

Ed Sheeran says he had a stutter after a birthmark removal surgery when he was 9. Sheeran thinks the procedure affected his nervous system, leading to the stutter. (Getty Images / File)

CLICK HERE TO GET THE FOX NEWS APP

Sheeran said he can relate to Eminem because they both live in their hometowns, surrounded by their people. According to Sheeran, meeting Eminem helped him feel less like a "zoo animal" or an "alien" because Eminem deals with "kind of the same thing."

Sheeran is coming off his victory in his copyright infringement lawsuit. He was accused of copying music chords from Marvin Gaye's classic "Let's Get It On" in his 2014 hit song "Thinking Out Loud."