British rocker Pete Doherty smiled and hugged fans outside court on Monday after a judge ruled he will not serve jail time for possession of drugs including heroin and crack cocaine.

District Judge Jane McIvor ordered the 27-year-old Babyshambles singer to pay 770 pounds (US$1,525) in fines and court costs and forbade him from driving for four months.

"I feel relieved," Doherty told reporters outside Thames Magistrate Court in London.

Click here to visit FOXNews.com's Celebrities in Trouble center.

The singer from east London was arrested in April for possession of less than 2 grams each of heroin, cannabis and cocaine, just three hours after he was sentenced to two years of community service for previous drug offenses. The drugs were found in the vehicle he was in and at his home.

Doherty was arrested again Aug. 7 with a crack pipe and a small amount of crack cocaine, and pleaded guilty Aug. 18 to all five counts.

"He's not going to jail. It's amazing," said 16-year-old fan Georgina Raymond, who jumped up and down screaming into her cell phone, "I hugged him!"

In September, McIvor told Doherty he would not serve jail time for the charges if he continued rehabilitation, stayed employed and did not commit any other offenses. She also complimented him for his song, "The Blinding." Doherty did not break any of the imposed restrictions, McIvor said.

"Hitting your pocket is the way of punishing you in this case," McIvor said Monday. Doherty has been in and out of court on drug charges and spent time at the Priory rehabilitation clinic.

His lawyer, Sean Curran, said there had been a "breakdown" in Doherty's rehabilitation. Curran gave no details, but said he hoped Doherty would continue to make an effort to break his drug habit.

In November, Doherty, the on-off boyfriend of supermodel Kate Moss, was fined 750 pounds (euro1,115 US$1,485) for assaulting British Broadcasting Corp. reporter Trudi Barber outside the same court.

His drug habit gained international attention after a British tabloid printed pictures of Moss allegedly using cocaine at a music studio where Doherty and his band were recording. Moss was not charged.