Actress Lindsay Lohan was ordered on Monday to spend 90 days in a locked rehabilitation facility and undertake 30 days of community labor as part of a plea bargain with prosecutors in which she will avoid time in jail on charges arising from a June car crash.
Los Angeles Superior Court Judge James Dabney said Lohan, 26, must also undergo psychotherapy for 18 months and sentenced her to two years' probation.
The agreement came on the first day of a scheduled trial when Lohan agreed to plead no contest to charges that she lied to police when she said she was not behind the wheel after her Porsche sports car smashed into a truck on June 8, 2012, in Santa Monica, California.
Lohan, who is still on probation for a 2011 conviction for stealing a necklace, had faced the prospect of being sent to jail if she was convicted on the latest charges, or if she was deemed to have violated the terms of her probation.
Under Monday's plea bargain however, she was given a suspended 180 day jail term that will not be invoked unless she violates the terms of the agreement with prosecutors.
The plea bargain was announced after prosecutors and Lohan's attorney met with Dabney in chambers for more than two hours before the trial opened.
Dabney told Lohan to stay out of cars and out of trouble.
"A suggestion: Don't drive. You're in New York, you don't need a car. ... This is it. If you violate your probation we're not going to be having these discussions," he said after reading out the plea agreement.
The "Mean Girls" actress has been to jail for brief periods and entered rehabilitation for drinking and drug problems several times since 2007.
Lohan, who arrived 45 minutes late for the trial, had previously pleaded not guilty to reckless driving, obstructing police, and lying to police about who was driving the car in June 2012.
Lohan's once promising Hollywood career has been seriously damaged by her numerous legal troubles. A comeback performance as late actress Elizabeth Taylor in the TV movie "Liz & Dick" in November was largely panned by critics.