They found Elvis face down on the floor of his bathroom, his body slumped on the vomit-stained red shag carpet in front of the toilet. The King was dead. On the evening of 16 August 1977, the 42-year-old singer had taken Seconal, Placidyl, Valmid, Demerol and an assortment of other drugs before putting on his gold pyjamas, the bottom half of which was now crumpled around his ankles. Beside him lay a book about sex and psychic energy – or, depending on whose account you believe, a copy of A Scientific Search for the Face of Jesus by Frank O Adams.

Sex, drugs and rock’n’roll are a well-established trinity, but to that list we could very reasonably add God. As Elvis explained, “Rock’n’roll is basically just gospel music, or gospel music mixed with rhythm and blues.” Scientists at the University of Utah demonstrated last year that, among a test group of 19 devout Mormons, “A recognisable feeling central to their devotional practice was reproducibly associated with activation in nucleus accumbens, ventromedial prefrontal cortex and frontal attentional regions” – which, in plain English, means that religious experiences can have the same sort of effect on the brain as sex, drugs and love. Faith, then, should be natural material for rockers, and so it has proved in the music of Elvis, U2 and even Black Sabbath.

But few considered it good news when Bob Dylan was born again in November 1978. Like the Who’s Pete Townshend, who had heard “the voice of God” (in his case an Indian mystic) while staying at a drab Holiday Inn in Illinois, Dylan was on tour when the Lord came for him.

Approaching his forties and recently divorced, Dylan had been feeling miserable and unwell for some time. At a show in San Diego, he was visibly struggling when a fan tossed a silver cross at him. He watched it land by his feet. “Usually, I don’t pick things up that are thrown on the front of the stage,” he later recalled, “but I looked down at this cross and I said, ‘I got to pick that up.’”

The following night, wearing it around his neck while trying to doze off in an Arizona hotel room, he was suddenly touched by God’s grace, healed by His word and delivered by His hand. “There was a presence… that couldn’t have been anybody but Jesus,” he told the LA Times in 1980, still in the long initial flush of his romance with evangelical Christianity. “I truly had a born-again experience, if you want to call it that.”

Born the first time round as Robert Zimmerman to Minnesotan Jewish parents in 1941, Dylan had largely abandoned his family’s religion when he changed his name and refashioned himself as a Dust Bowl folk singer in the early 1960s. (His spoken-word introduction to “Talkin’ Hava Negeilah Blues”, put to tape in 1963, merrily calls it “a foreign song” as if celebrating his estrangement from Judaism.) Yet the language of religion had informed Dylan’s work since his earliest recordings, whether in the form of Christian folk covers (“Gospel Plow”) or ominous scriptural lyrics about divine justice (“When the Ship Comes In”).

By the time he released Slow Train Coming (1979), his first album consisting of only devotional music, Christianity had become not just source material for Dylan but his monomaniacal focus. Jesus had once been invoked in his lyrics as a kind of cultural shorthand alongside Shakespeare, Achilles, Mr Clean, Aretha Franklin and TS Eliot – as one mythological character among a cast of many – but now he was “the way, the truth and the life”. And the singer’s Messiah wasn’t the God of love, but an archly conservative God of vengeance.

Dylan the convert derided abortion and casually referred to San Francisco as “a dwelling place for homosexuals”. He wrote nasty lyrics about Arabs “walkin’ around like kings/Wearing fancy jewels and nose rings”, and launched into lengthy, hectoring speeches at live performances in which he welcomed what he saw as the coming annihilation of mankind. “Don’t be dismayed by what you read in the newspapers, about what’s happening to the world,” he said at a show in Tempe, Arizona. “The world as we know it is being destroyed… There’s gonna be a war… called the War of Armageddon. It’s gonna happen in the Middle East. Russia will come down and attack first. You watch for that sign.”

Fans were dismayed, and with much justification. Here was the once lusty singer of “Lay Lady Lay” complaining, as he did in Montreal, of women who live “from orgasm to orgasm”. In order to commit to God, Dylan had evidently felt it necessary to deny his – and everybody else’s – physical self. He would face rock audiences and quote sternly at them from James 4:4: “A Friend of the world is the enemy of God.”

Some long-time allies, such as Jann Wenner, the Rolling Stone editor, did their best to help Dylan spread his gospel even if they didn’t believe it themselves. Wenner wrote a review of Slow Train Coming that praised it as “the best album Bob Dylan has made since The Basement Tapes”, but was careful to include an infidel’s proviso: “The words finally don’t matter at all.”

For many of Dylan’s listeners, however, they did. As in 1965, when he “went electric” and alienated folkies with his new rock combo, there were reports of walkouts and widespread heckling at his Christian concerts. Dylan, who was awarded the Nobel Prize in Literature last year, has long claimed to be a mere “song-and-dance man”. Yet what first distinguished him from his peers were his words and the way he phrased them at the microphone. Now, in his worst gospel songs, he offered only a single message delivered in a series of uniformly shrill yelps: repent and convert, or else.

The problem, I think, was less his personal religious views than the narrowness of his new lyrical concerns. In much of his best work, he is thrillingly imprecise. In the late-1990s song “Red River Shore” (which for my money is the greatest thing he has ever written), he moves effortlessly from wishing he “could have spent every day of my life” with a lost love to a story of “a guy” who could raise the dead – Jesus again – with little need for explanation. What holds it all together is his committed vocal, the beauty of the music and the sense that beyond the song exists a larger world that we can only imagine.

Meanwhile, in the gospel-era “Do Right to Me Baby” we are instructed, “Do unto others like you have them… do unto you,” over five verses that add little of any substance to the title. The poetry often died when the preaching began.

But Dylan was not to be deterred. Month after month he travelled across America and then across Europe with his Christian revue, which began with a backstage prayer meeting for the band, followed by a mini-set of hymns performed by the female backing singers. Then Dylan would take to the stage and present one Bible basher after another, ignoring his better-known and better-loved earlier material. Attempting to convert his entire audience, he interspersed the music with speeches that often sounded like the threats of a warlord or the witchfinder general: “Every knee shall bow, every tongue will confess!” When the response was hostile, he blamed it on the Devil, whom he claimed was “working all kinds of mischief in the crowds we visit”.

By mid-1980, his record label had had enough. According to the British pop manager Simon Napier-Bell, Dick Asher, Columbia’s deputy president, was overheard screaming at Dylan: “No Torah! No Bible! No Quran! No Jesus! No God! No Allah! No fucking religion. It’s going in the contract.” The 1981 record Shot of Love accordingly compromised by including secular (or secular-sounding) songs such as “Lenny Bruce” and “Heart of Mine” – though its strongest moments were religiously themed.

And that’s the surprising thing about Dylan’s evangelical Christian period: it isn’t all bad. Some of it – the Blakean “Every Grain of Sand”, the stirring hymns “Pressing On” and “Saving Grace”, the powerful confessional “When He Returns” – is among the most deeply felt and affecting recordings of his career. Sifting through the new retrospective album Trouble No More, which covers the years 1979 to 1981, I found startlingly good live performances of songs such as “What Can I Do for You?”, as well as previously unreleased gems such as “Ain’t No Man Righteous, No Not One”.

Clinton Heylin’s new book, Trouble in Mind, documents the tours and recording sessions with an obsessive detail that, at the very least, encourages the reader to come at it all afresh. Heylin claims that the gospel period “more than matches any commensurate era in [Dylan’s] long and distinguished career”, which is plainly a factual error. But his interrogation of what it was all for is, to fans like me, highly illuminating.

Despite being an atheist, I’ve always had a weird fondness for gospel-era Bob, even in his most disappointingly dogmatic moments. Just as I don’t have to condone senseless murder to love Johnny Cash’s “Folsom Prison Blues” (“I shot a man in Reno just to watch him die”), I feel no compulsion to agree with anything Dylan has to say about God in order to be moved by his songs of praise and mean-spirited condemnation. But when, in “Saving Grace”, he sings, “There’s only one road and it leads to Calvary,” his voice straining and the organ exploding in ecstatic joy, I am almost converted. Almost. In a 1997 Newsweek interview, a less aggressively spiritual Dylan said: “I find the religiosity and philosophy in the music… The songs are my lexicon. I believe in the songs.” I suppose I believe in them, too.

Clinton Heylin’s “Trouble in Mind: Bob Dylan’s Gospel Years – What Really Happened” is published by Route