Lindsay Lohan Lindsay Lohan

Lindsay Lohan will go back to rehab — not jail — for a failed drug test.

Los Angeles Superior Court Judge Elden S. Fox ordered the actress to continue rehab at the Betty Ford Center until Jan. 3 at her probation violation hearing on Friday.

Prosecutor Danette Meyers recommended six months in jail, but Fox chose rehab after reviewing a written letter from Lohan.

Lindsay Lohan bails out of jail hours after sentencing

"You are an addict. I hope you understand that," Fox told Lohan, who cried during the hearing.The 24-year-old is due back in court Feb. 25 and is subject to random drug testing in between her release from rehab and the court date. Fox said that any violation will result in a mandatory 180-day jail sentence.The judge had previously threatened 30 days in jail for Lohan for every drug test she missed or failed. Lohan was taken into custody last month without bail after she admitted to failing a drug test. She bailed out hours later because Fox's ruling clashed with California state law, which gives defendants the right to bail in misdemeanor cases.

Lindsay Lohan fails drug test, says she's prepared for consequences

Shortly after her release, Lohan checked in to the Betty Ford Center.Fox's ruling Friday means Lohan avoids returning to jail for a fourth time, stemming from a 2007 DUI charge. She served 84 minutes that year and then 13 days of a 90-day sentence this summer for violating probation, after which she attended a drug-rehab program.