Keith Richards has made a lifelong habit of flirting with disaster and coming out on the winning end, but he's had a few close calls along the way. On Feb. 27, 1977, he suffered one of his most infamous brushes with the long arm of the law.

In Canada with the Rolling Stones to record some live dates at the El Mocambo in Toronto, Richards met with trouble immediately; after he and partner Anita Pallenberg got off the plane — upon which Richards had indulged in heroin — authorities were waiting to search both of them, and ended up hauling her off to the hoosegow. "I took a hit on the airplane and somehow the spoon ended up in Anita’s pocket," Richards wrote in his Life memoir. "They found nothing on me at the airport, but they found the spoon on Anita and busted her."

After nabbing Pallenberg, according to Richards, the Canadian police "bided their time" building their case against him. Alleging that they staffed his hotel with an array of undercover officers and illicitly intercepted the stash he'd sent ahead, he described a massive sting operation in which policemen dressed as waiters finagled their way into his room, where he was zonked out after staying up for days and getting high. Finally managing to get Richards awake — as he wryly noted, "you have to be conscious to be arrested" — they hauled him in.

"Meanwhile they’d found my stash. And it was about an ounce. Quite a lot," he wrote. "No more than a man needs. I mean, it wouldn’t feed the city. But obviously they knew their s---, like I knew my s---, and it was clearly not the Canada smack. It had come from England. I’d put it in the flight case."

It all added up to a mess of trouble for Richards, whose legal entanglements cast no small amount of public doubt upon the future of the Stones. He was charged with possession of heroin with intent to traffic — a charge that could have carried a life sentence, and sent the guitarist's legal team whirring into high gear. Seeking to prove he'd cleaned up his act, Richards dove into rehab after the bust, undergoing "neuroelectric acupuncture" on the recommendation of his friend Eric Clapton. Aside from keeping him on the (relatively) straight and narrow over the short term, it allowed Richards' lawyers to present something like proof that he was at least trying to kick his habit.

Fortunately for Stones fans, the gambit worked. On Oct. 24, Richards pleaded guilty to possession, plea-bargaining down from trafficking. That charge still carried a seven-year maximum, but he left the courtroom a free man after the judge settled for handing down a year of probation and a one-year suspended sentence.

"No incarceration or fine would be appropriate," decreed York County Judge Lloyd Grayburn, "because of Mr. Richards' continuing treatment for drug addiction and his long-term benefit to the community, to the large community."

After Grayburn's sentence, Richards was free to go — but he was still on the hook to return to Toronto, where the judge ordered him to return within six months and perform a free concert for the blind. It was a decision not without its detractors, and the Stones ran into further difficulty when they tried to come back for the gig, but it all eventually worked out — and found singer Mick Jagger in reasonably good humor too. Months after watching what might have been the end of his band, he strolled out onstage and quipped to the crowd, "It's great to be back in Toronto — we've got a special relationship here."

Even after getting out of jail free, Richards wasn't finished turning lemons into lemonade. The Stones' charity Toronto shows, scheduled for April of 1979, took place during a hiatus for the band — and immediately thereafter, he took off on an 18-date tour with their support act the New Barbarians, a supergroup assembled on a lark by bandmate Ron Wood in support of his own Gimme Some Neck solo LP.

Keith Richards Year by Year

More From Ultimate Classic Rock