Of all Johnny Cash's many and varied incarnations, that of 1980s indie connoisseur might just be the strangest. "Hearing Cash raving about Gaye Bykers on Acid was definitely one of the highlights of my life," says Marc Riley, laughing. "He was really on it, reeling off the names. I remember him talking about That Petrol Emotion. It was pretty incongruous."

Today, Riley is a pillar of BBC 6 Music. Twenty-odd years ago, he was a former member of the Fall, harbouring an urge to make the first Johnny Cash tribute album. With help from Jon Langford of country-punk trailblazers the Mekons, he succeeded. Released on Red Rhino in 1988 and long out of print, 'Til Things Are Brighter featured a who's who of 80s indie, punk and pop stalwarts. Marc Almond sang Man in Black; Pete Shelley yelped his way through Straight A's in Love; and yes, Mary Mary from psychedelic grebo rockers Gaye Bykers on Acid tore up A Boy Named Sue, adding a salty "motherfucker" where a "son of a bitch" used to be.

It's a raw, raucous, occasionally rather ropey tribute, yet also oddly auspicious. Incongruous though it seems for such a quintessentially American artist to find his oeuvre redefined in the studios and pubs of Leeds, Manchester and London, Cash's affiliation with this ragged group of British-based musicians was the first step on a long road back to critical and commercial relevance, following a decade in which he had slid into something close to cultural inconsequence.

Almost two decades after Rick Rubin delivered him to a new audience with the landmark American Recordings album, it's hard to imagine a time when Cash wasn't synonymous with cool – yet in 1988, things looked very different. Dropped in 1986 by Columbia, his record company of 30 years, and without a hit single or album for a decade, Cash had not only been marginalised by the country music industry but, in his early 50s, was creatively stymied. Meanwhile, his core audience was verging on the prehistoric.

"I had grown up listening to him as a really young kid, and it stayed with me," Riley says. "But he wasn't on the radar for most people who grew up listening to Bowie and the Stooges. We'd go and see him through the 1980s at the Manchester Apollo or the Palace, or in Blackpool, and 95% of his audience was the purple-rinse brigade. It was close to cabaret. There was no credibility associated with it – he was probably at his lowest point of cool." Langford recalls: "There were no youthful hipsters at his gigs. Me and Marc were definitely the youngest people there."

Yet Cash's aura remained powerful, with residual traces of the pill-popping menace that defined him in his heyday. As he found himself drifting beyond not only the attentions of the US country music establishment but almost everyone else in his homeland, it was overseas that he found a welcoming arm around his shoulder.

Nick Cave's music in particular often sounded like the final, brutal flurry of blows in a fight Cash had started back in the mid-1950s. On their 1986 covers album Kicking Against the Pricks, Cave and the Bad Seeds recorded The Singer, the little-known B-side of Cash's live version of Folsom Prison Blues, released in 1968. A year earlier, on The Firstborn Is Dead, Cave had recorded Wanted Man, the tongue-in-cheek travelogue of a ladykiller on the lam, written in 1969 by Cash and Bob Dylan and recorded days later on the live album At San Quentin.

Cave's endorsement not only joined the dots between Cash and more overtly cool cult artists such as Lee Hazlewood, Sanford Clark, the Velvet Underground and Duane Eddy. It also made explicit Cash's affiliation with a crop of indie artists who may not have been selling a bucketload of records but who were, at the time, bellwethers of the alternative music scene.

Among them was Cathal Coughlan, who covered Ring of Fire for 'Til Things Are Brighter. His former band Microdisney would often perform Cash's version of Cocaine Blues. "It wasn't ironic at all," he says. "It was straight-down-the-line rebellious. Someone had made me a mixtape in 1982 of the Sun Records stuff and it just blew me away. I knew him since as this kind of cabaret figure – he had faded, definitely, but I still had a lot of regard for him, and that album seemed to get him into some interesting places."

'Til Things Are Brighter wasn't a lavish affair. Langford, Riley and their house band "bashed out" all 13 backing tracks in a single day at RikRak studio in Leeds; the vocalists added their contributions over the next few weeks at Berry Street studios in Clerkenwell. Michelle Shocked galloped through One Piece at a Time, and the Triffids' David McComb crooned Country Boy, a 1957 Cash original. Langford recalls that Marc Almond, the one "proper" pop star taking part, came in and "told me I'd cut Man in Black in the wrong key. He had a horrible fit in the studio. Sally [Timms, from the Mekons] talked him down and coaxed this fantastic performance out of him, but I think he was a bit nervous. It was maybe a bit odd for him to be doing Johnny Cash songs."

Cash thoroughly approved. He was thrilled at a new generation of musicians interpreting his songs, even if in reality that meant Cabaret Voltaire's Stephen Mallinder loping through a version of I Walk the Line which could charitably be described as pitchy. When he toured the UK in May 1988, he hooked up with Riley and Langford backstage at Manchester Apollo and posed for the photo that was used on the back of 'Til Things Are Brighter. In 1989, while being interviewed by the BBC, he held a copy of the album up for the camera, reeled off a few of the artists – "Tracey and Melissa from Voice of the Beehive" – and said how proud he was of the album these "young people" had made.

Cash, however, was genuinely peeved when he discovered that the album launch at the Old Pied Bull pub in Islington was going to be held just days after he was scheduled to leave the UK. "I wish I'd known," he said. "June and I would have stayed over." "He would have done it, too," says Langford. "Sharing a dressing room with Frank Sidebottom …"

Aware that the idea of releasing a Cash tribute in 1988 seemed "a bit gratuitous", it was decided to make the album a benefit for the Terence Higgins Trust. At the time, HIV/Aids was still widely perceived as an issue that almost exclusively affected the gay community. "We didn't know what his reaction would be when we told him it was a benefit for Aids, but he was very cool about that," says Riley. "He said it was great that young people were doing his music for a cause that hadn't really been dealt with at that point."

The album's primary aim was to raise funds and awareness, but it also undoubtedly boosted Cash's confidence. It's easier now, almost 25 years later, to understand and see the wider significance of his enthusiastic engagement with 'Til Things Are Brighter. "He told us it was a morale booster," says Langford. "He was very flattered and supportive. I later learned from his guitarist, Marty Stuart, that he was really pissed off and apparently quite depressed around this time. He felt ignored and irrelevant, and when you hear Gaye Bykers on Acid covering your songs I guess you know you're not irrelevant."

"He felt a real connection with those musicians and very validated," says his daughter Rosanne Cash. "It was very good for him: he was in his element. He absolutely understood what they were tapping into, and loved it. That album was definitely re-energising for him."

The album also altered the context in which he was regarded by many critics and younger listeners. In the US, the Chicago Tribune ran a feature entitled Johnny Cash Meets the Hip Britons, while the album was discussed on college radio and reviewed in most alternative music magazines; much the same places, in fact, that later embraced American Recordings. In the UK, NME and Melody Maker sat up and took notice. "Some people didn't really get that Cash was a serious artist. They thought we were indulging a bit of kitsch," says Langford. "We just thought of it as showcasing these great songs."

"Its profile was quite high and it got good reviews," Riley says. "Cash hadn't yet been rediscovered as a cultural icon, but he still generated excitement. It was a good story: the Mekons, Marc Almond, elements of the Fall all choosing a country star with not very much credibility." This was precisely the marketing angle Rubin fully exploited a few years later when he set about rebranding Cash and encouraging him to cover songs by the likes of Cave, Soundgarden and Nine Inch Nails.

Perhaps the most significant consequence was less immediately visible. Hearing his songs shaken and stirred by a bunch of indie musicians engendered a subtle shift in the way Cash perceived himself as an artist. He had always been an honorary member of any musical constituency claiming a vaguely outsider status. After years of trying to conform to the Nashville establishment's rather orthodox notion of who he was and what he should do, 'Til Things Are Brighter informed his own sense of isolation and helped him re-engage with his core identity as a genuinely alternative artist. This realisation eventually led him to the breakthrough of American Recordings.

If meeting and recording with Rick Rubin was in many ways the final and most significant piece of the jigsaw, 'Til Things Are Brighter is at least part of the same picture. No one will ever mistake the plain-speaking, pretension-skewering Riley for Rubin, a self-styled guru-producer who contemplates music with his legs crossed and his eyes closed as though weighing up some great cosmic calculation rather than the latest Dixie Chicks album. Yet both men had a role in pointing Cash towards his extraordinary final decade of music-making.

"It was like a pre-echo of his stature, that he wasn't forgotten," says Riley of the album. "He wasn't Tom Jones, he hadn't gone off to Vegas – there was an artist in there who was troubled by complacency. I'm not blowing our trumpet. What Rick Rubin achieved with him dwarfed what we did. But I'd like to think we played our part and were a bit ahead of our time."

The Resurrection of Johnny Cash: Hurt, Redemption and American Recordings, by Graeme Thomson, is published by Jawbone Press.