To fans across the world, it is one of the emblematic songs of the 60s, a rousing, catchy love song to a girl known simply as Sweet Caroline. Now, almost 40 years after its release, the singer and songwriter Neil Diamond has revealed the inspiration behind the song: the Caroline in question was Caroline Kennedy, now the only surviving child of president John F Kennedy.

"I've never discussed it with anybody before - intentionally," Diamond, 66, told Associated Press. "I thought maybe I would tell it to Caroline when I met her someday."

Diamond came clean, telling both the press and the song's subject about its origin, when he finally met the now Caroline Kennedy Schlossberg, and performed the song for her 50th birthday.

"It was a No 1 record and probably is the biggest, most important song of my career, and I have to thank her for the inspiration," he said.

"I'm happy to have gotten it off my chest and to have expressed it to Caroline. I thought she might be embarrassed, but she seemed to be struck by it and really, really happy."

The inspiration for the song came from a photograph of the then nine-year-old Kennedy the singer saw in a magazine while staying at a hotel in Memphis.

"It was a picture of a little girl dressed to the nines in her riding gear, next to her pony," Diamond said. "It was such an innocent, wonderful picture, I immediately felt there was a song in there."

A few years later, Diamond penned the song inspired by the photograph. It became a hit, reviving his flagging career and eventually selling more than 2m copies and providing countless karaoke singers with a chance to shine.

The enduring hit recently reappeared in the singles chart in the US, thanks in part to the fact that it is belted out during home games at Fenway Park, home to the Boston Red Sox baseball team.

"I think they consider it good luck," Diamond told the Associtated Press, adding that the Red Sox have become his favourite baseball team.