Babyshambles singer Pete Doherty has been given a 12-month community order after admitting possession of drugs.
The 26-year-old was sentenced at Ealing Magistrates' Court.
The singer was also ordered to take part in a drug rehabilitation programme and warned he could face jail if he breached the order.
Doherty had been held in custody since being arrested by plain clothes police officers in Whitechapel, east London, on 26 January.
He pleaded guilty to a total of seven charges of possessing illegal substances at three separate court appearances last month.
The year-long drug rehabilitation programme will require Doherty to attend a drug centre and undergo monthly check-ups.
Magistrate Ann McLaughlin told Doherty: "You must submit to treatment with a view to ending your dependency on drugs."
More than 40 journalists and about 30 fans crammed into the court for the sentencing.
Speaking after the hearing, fellow Babyshambles member Adam Ficek said: "We are thrilled for [Pete] and for the band and we can go forward now.
The band's bassist Drew McConnell added: "We did not speculate [on the sentence]. We were very nervous about what the sentence would be but it's a result.
"We can't wait to see Pete and make plans for the rest of the year."
Both men said they would support Doherty in his battle against drug addiction.
"I think some people just have a natural knack for summing up how a whole generation feels with a few words and a few notes," added Mr McConnell.
"[Pete] still finds it hard to believe that he has that talent sometimes."
Mr Ficek added: "He is very talented in a musical sense and with the written word. The general public have yet to recognise that."
Doherty shot to fame as lead singer of the Libertines and became a tabloid regular during his relationship with model Kate Moss.