The sentence by Superior Court Judge Stephanie Sautner was aimed at keeping close tabs on Lohan, who acknowledged she recently violated court orders by getting booted from a community service assignment at a women's shelter.
Lohan has been in court numerous times since her legal problems began in 2007 with a drunken driving case.
Sautner warned the actress that more time behind bars awaited if she messed up again.
In reality, however, the initial 30-day sentence will be significantly shortened by jail overcrowding, and sheriff's officials said she may only be at the jail for a few hours. In 2007, the actress spent 84 minutes at the jail before being released, and in the past she has served about 20 percent of her sentence, which is roughly six days. The actual length of the term will be set by the Sheriff's Department, which oversees county lockups.
The 25-year-old actress has until Nov. 9 to report for her jail term, and Sautner ruled she cannot serve house arrest, as she did previously this year.
The sentence also requires Lohan to perform community service assignments at the county morgue, undergo psychotherapy sessions, and appear monthly at court hearings between December and March.
The judge also said Lohan can no longer leave the country and needs the permission of her new "no-nonsense" probation officer to travel outside California.
In recent months, Lohan has been jet-setting, appearing in New York during Fashion Week and overseas for modeling gigs.
If Lohan fails to follow the terms imposed by the judge, she will be sent to jail for 270 days, Sautner said, explaining the approach was known as "putting the keys to the jail in the defendant's hands."
In court, the actress, wearing a polka-dotted dress, spoke only to acknowledge she understood the terms of her sentence.
Similar arrangements with Lohan have failed. A year ago, a judge in Beverly Hills sent her to rehab until January and told her if she stayed out of trouble, she would no longer be court-monitored and would be free to leave Los Angeles.
It was not to be. At rehab, Lohan was accused of battery on a worker, although charges were never filed. Within three weeks of her release, Lohan was accused of taking a $2,500 necklace without permission and eventually pleaded no contest to a misdemeanor theft charge.
Sautner then sentenced Lohan to four months in jail in the theft case. The term, however, was reduced to 35 days on house arrest due to jail overcrowding - an outcome that led the judge at a recent hearing to express exasperation with the actress and California's cash-strapped jail system.
Sautner said Wednesday she would not hesitate to return Lohan to jail for nearly nine months if she failed again and laid out strict guidelines for her freedom.
Lohan will have to serve 423 hours at the county morgue, where for nearly two weeks she has been mopping floors, cleaning bathrooms and washing dirty sheets. She will also have to attend 18 psychotherapy sessions between now and March after missing several in recent months.
The judge noted that Lohan's popularity in certain circles is low, saying another women's shelter refused to accept her for a community service assignment because she was considered a bad example for the women.
Lohan's previous probation officer also wanted off the case, and the new officer is under orders to immediately report any violations directly to Sautner.
The actress has now been sentenced to county jail five times since being arrested twice for drunken driving in 2007, and each of her incarcerations has been shortened due to overcrowding.
Her current court troubles came after she was terminated from the shelter program after failing to show up nine times at the center. She told her probation officer the assignment was not fulfilling, according to a probation report. Sautner had sent Lohan to the facility in downtown Los Angeles, thinking that it might benefit the actress.
Now the judge says all of Lohan's community service hours will be spent at the morgue.
That assignment has not been without drama. She was turned away the first day after showing up 40 minutes late but has shown up early several times since then. Assistant Chief Coroner Ed Winter declined Tuesday to characterize how Lohan's service was progressing.
Sautner told Lohan that the coroner's office was unhappy with her posting Twitter updates about her experience and that she should stop. In turn, the judge said she told the agency not to hold any press conferences about Lohan, as they had done on the day she was turned away.
Lohan's probation on her four-year-old drunken driving case was extended until March, and she remains on probation in the necklace theft case until 2014.
Sautner said the restrictions may be lifted early if Lohan completes her service and counseling before the court's deadlines.