Sinead O’Connor and Prince, passionate singer-songwriters who both died in their mid-50s, were tied together by the plaintive song “Nothing Compares 2 U,” which catapulted O’Connor to fame when she recorded it for her sophomore album.

Prince had composed the song in 1984, deciding to give it to the Family, a side project featuring the singers Susannah Melvoin and Paul Peterson. But the track never gained much recognition when the band released its self-titled album in 1985.

The response was considerably different when O’Connor, working with the Japanese jazz musician Gota Yashiki and the producer Nellee Hooper, recorded a stripped-down version for her 1990 album “I Do Not Want What I Haven’t Got.”

“Nothing Compares 2 U” became a No. 1 hit in 17 countries, topped the Billboard Hot 100 for four straight weeks and helped win O’Connor a Grammy (which she later refused to accept). The track’s popular music video, featuring a close-up of O’Connor’s shaved head and piercing gaze, was itself nominated for a Grammy.

“As far as I’m concerned, it’s my song,” O’Connor told The New York Times in 2021.

Prince was pleased to see O’Connor’s version become so popular, Melvoin said in an interview this week.

“When it hit and it was doing remarkably well, he had a big smile on his face about it.” Melvoin said. “He loved it. At one point later in his life, he was known to say, ‘Thank you for all the beautiful houses, Sinead.’”

Peterson said he was so shocked when he first heard O’Connor’s cover over the car radio that he had to pull over.

“I didn’t know who she was, and I felt like I had ownership in that song even though I didn’t write it,” he said in an interview. “So I think I was a little disappointed that our version didn’t get out there at the incredible rate that hers did.”

At the same time, Peterson said, he feels thrilled that O’Connor’s cover has been so influential. “It’s incredible the amount of people’s lives that song has touched,” he said. “I was just thrilled to be a small part of that”

Melvoin said Prince wrote the song both about herself and his housekeeper, Sandy Scipioni, who left the role after her father died. Melvoin and Prince had been intimately involved for years, she said, but were encountering difficulties in their relationship when he wrote “Nothing Compares 2 U.”

It took only a short time for Prince to draft the song at his Eden Prairie warehouse studio, Susan Rogers, Prince’s sound engineer, said in Duane Tudahl’s book “Prince and the Purple Rain Era Studio Sessions.”

“I was amazed how beautiful it was,” Rogers told Tudahl. “He took his notebook and he went off to the bedroom, wrote the lyrics very quickly, came back out and sang it.”

O’Connor wrote in her memoir, “Rememberings,” that she felt a particular resonance with the lines, “All the flowers that you planted Mama/In the backyard/All died when you went away.”

“Every time I perform it, I feel it’s the only time I get to spend with my mother and that I’m talking with her again,” wrote O’Connor, who was 18 when her mother died in a car crash. “There’s a belief that she’s there, that she can hear me and I can connect to her.”

Although “Nothing Compares 2 U” was vital to O’Connor’s career, she grew conflicted about Prince, writing in her memoir about a distressing encounter at his Los Angeles residence.

They had first met at a club around the time of O’Connor’s debut album in 1987, she wrote, but did not interact again until after her version of “Nothing Compares 2 U” became a hit in America.

When O’Connor arrived at Prince’s residence, she wrote, the singer criticized her for swearing in interviews. Prince then suggested the two engage in a pillow fight, she wrote, and began hitting her with a pillowcase containing a pillow and some hard object.

O’Connor fled and Prince pursued her in his car, she wrote, until she escaped to a nearby home. (A spokeswoman for Prince’s estate did not respond to requests for comment.)

“I never wanted to see that devil again,” O’Connor wrote.