Syd Barrett's tortured spirit was already hovering over Pink Floyd's ninth studio album, Wish You Were Here – even before he unexpectedly crashed the studio sessions on June 5, 1975.

Both the emotive title track and shimmering, psychedelic epic "Shine On You Crazy Diamond" were inspired by Barrett, the band's fledgling former frontman, with chief writer Roger Waters meditating on themes of isolation and inward escape. So when the long-absent musician – portly, with distant gaze, shaved head and eyebrows – randomly arrived during a mixing session for "Diamond" on June 5, the coincidence reduced the band to a mixture of shock and depression.

It's not as if Barrett, Floyd's co-founder and the driving creative force behind their debut LP, 1967's The Piper at the Gates of Dawn, left the band on good terms. His mental instability, erratic stage behavior and addiction to LSD made him a liability, and guitarist-singer David Gilmour was brought in as a temporary – then permanent – replacement.

Barrett made minimal contributions to 1968's A Saucerful of Secrets, but his warped mysticism ultimately vanished: He released two studio albums – 1970's The Madcap Laughs and Barrett, both co-produced by Gilmour and featuring Waters and keyboardist Richard Wright, respectively – but the troubled musician rarely worked after that point, eventually retreating from the spotlight.

Barrett's fortunes seemed to be changing in 1974, when the rejuvenated songwriter made some formative – but ultimately fruitless – recordings at Abbey Road. But when he crashed the same studio during Floyd's session less than a year later, he was bloated and mentally foggy – a sad shell of the psychedelic warrior whose warped vision guided Floyd to stardom.

The band was confused by his presence, assuming he had to be a crew member. But when Gilmour eventually identified their former bandmate, Waters broke down in tears. That June day also happened to be Gilmour's wedding day, so Barrett wandered into the guitarist's wedding reception at EMI. He left without telling anyone, disappearing as strangely as he'd arrived.

The experience had a profound impact on the band, particularly Waters, who even incorporated a lyrical reference to the Barrett-penned single "See Emily Play" on the LP.

"I'm very sad about Syd, [though] I wasn't for years," Waters commented in 1975. "For years I suppose he was a threat because of all that bollocks written about him and us. Of course, he was very important and the band would never have f---ing started without him because he was writing all the material. It couldn't have happened without him, but on the other hand, it couldn't have gone on with him. He may or may not be important in rock 'n' roll anthology terms, but he's certainly not nearly as important as people say in terms of Pink Floyd. So I think I was threatened by him."

Gilmour, who co-wrote the music to both the title track and "Shine On," has trouble separating these classic songs from his memories of the former Floyd icon.

"Although 'Shine On You Crazy Diamond' is specifically about Syd and 'Wish You Were Here' has a broader remit," Gilmour said in the 2012 documentary Pink Floyd: The Story of Wish You Were Here, "I can't sing it without thinking about Syd."

See Pink Floyd and Other Rockers in the Top 100 Albums of the '60s

You Think You Know Pink Floyd?

More From 1073 Popcrush