A California judge ordered troubled actress Lindsay Lohan back to rehab until January of 2011 in lieu of sending her back to jail for failing a mandatory drug test last month.
Los Angeles Superior Court Judge Elden S. Fox ordered Lohan to remain at the Betty Ford Center until Jan. 3 and report back to court in late February.
A prosecutor had advocated a six-month jail sentence for the "Mean Girls" star, but Fox opted for rehab after reviewing filings by probation and rehab officials and a letter written by Lohan.
Lohan cried after hearing the sentence.
The judge acknowledged that Lohan, 24, has been in-and-out of court and rehab since a pair of high-profile arrests in 2007. He told the actress that he would not be manipulated by her, but was giving her a final chance to stay clean before adding that she would face jail time if she relapsed again.
"You're staying past the New Year's -- there's a reason for that," Fox said.
Fox's sentence means Lohan will not be returning to a suburban Los Angeles women's jail for a fourth time.
Her current legal woes are the result of drug and drunken driving charges being filed in 2007 after a pair of high-profile arrests.
Lohan arrived on time for the hearing, dressed in jeans, a dark blazer and aviator sunglasses. The 24-year-old actress was quiet and stone-faced as she walked through the crush of paparazzi outside.
Lohan reportedly left from rehab at the Betty Ford Clinic in California at 4 a.m.to make it to the hearing in Beverly Hills.
Fox had been expecting Lohan to arrive at court directly from jail, where he ordered her to be held on Sept. 24 after a brief hearing. Within hours, another judge had overturned his ruling and the starlet was released on bail.
The following week, a person close to the actress told The Associated Press, Lohan entered rehab for the fifth time. The source spoke on condition of anonymity because of the sensitivity of the issue.
Her recent court troubles have put Lohan's career on hold. She missed opportunities to promote her role in the summer film "Machete" because she was in jail and rehab. Her next starring role is supposed to be in a biopic on porn actress Linda Lovelace.
Friday's hearing was Lohan's fifth court appearance since May, when she ran into trouble with her probation on a three-year-old drug and drunken driving case.
In July and August, she spent 14 days in jail and 23 days in rehab as punishment for missing several court-ordered weekly counseling sessions.
Fox allowed her to be released from rehab early based on the recommendations of her doctors and laid out a path for her to be taken off probation by the end of the year. His regimen included frequent counseling sessions, meetings with probation officials and random drug screenings. It also included several incentives, including an assurance that if the actress complied with the terms for 67 days, her probation oversight would end and she would be free to move from Los Angeles. He also dismissed two drug charges that were filed after a pair of arrests in 2007.
Within weeks of her release from rehab, Lohan, 24, failed a drug test. She acknowledged the result in postings on Twitter and said she was struggling with addiction.
"I am a work in progress, just as anyone else," she Tweeted.
Fox had threatened to send her to 30 days in jail for each failed or missed test. He did not indicate at last month's hearing whether he was mulling other sentences.
Lohan's attorney, Shawn Chapman Holley, did not return e-mail and phone messages seeking comment.
When a judge sentenced her to three months in jail in July, she served 14 days as a result of overcrowding. She spent 84 minutes at the jail in 2007 before being released due to overcrowding.
Lohan pleaded no contest to two counts of driving with a blood-alcohol level above 0.08 percent and one count of reckless driving. She was sentenced to three years of probation, but that was later extended after the actress didn't complete the terms of her sentence in time.
The Associated Press and NewsCore contributed to this report.