Updated

Lindsay Lohan posted $300,000 bail Friday night, avoiding jail time after she failed a court-appointed drug test. She is scheduled to return to court for a second hearing on Oct. 22.

Los Angeles Superior Court Judge Elden Fox denied Lohan bail Friday morning and ordered that she remain in custody until the second hearing.

But just a few hours later, Judge Patricia Schnegg, Assistant Supervising Judge for the L.A. County Criminal Courts, threw out the ruling, setting bail the troubled actress’s bail at $300,000.

Bailiffs handcuffed Lohan immediately after Fox’s decision, which lasted less than 10 minutes at the Beverly Hills courthouse.

Lohan's father, Michael Lohan, said "Oh God" as his daughter rose, looked at her attorney and was handcuffed. Fox would not listen to arguments for bail from Lohan's attorney, Shawn Chapman Holley.

More On This...

It would have been Lohan's third jail stint for a three-year-old drug and drunken driving case filed after a pair of high-profile arrests in 2007.

Her previous stays at a women's jail in a Los Angeles suburb lasted 84 minutes and 14 days. In both cases, she was released from jail early due to overcrowding.

POLL: Is Lindsay Using Her Little Sister to Keep Money Flowing?

The judge said probation officials are reviewing Lohan's compliance with other aspects of her probation, which included frequent meetings with counselors.

Holley was not immediately available for comment. Court spokesman Allan Parachini said she remained in the courtroom to confer with Lohan.

Looking somber and wearing black and white clothing, the actress arrived 10 minutes early for the morning hearing. Cameras were not allowed inside the courtroom, and media lined the area outside awaiting the news.

It was the "Mean Girls" star's first appearance before Fox, who had said at a previous hearing he would sentence her to a month in jail for each drug test she skipped or failed.

The actress wasn't present for that hearing, which was held hours after her release from rehab.

Lohan acknowledged failing a court-ordered drug screening last week in a series of Twitter postings. At first she denied a report by TMZ that she had failed her drug test, but then she confessed on her Twitter page.

"Substance abuse is a disease, which unfortunately doesn't go away over night," Lohan posted on her Twitter feed last Friday. "I am working hard to overcome it and am taking positive steps.

"This is certainly a setback for me but I am taking responsibility for my actions and I'm prepared to face the consequences," her posts said.

The actress remains on probation for a reckless driving and two charges of driving under the influence, all misdemeanors. Fox dropped two drug cases at a hearing in August during which he announced Lohan's release from rehab, and he set out a strict outpatient treatment schedule that included random drug screenings.

Fox has sealed Lohan's court file, but a source familiar with the case has told The Associated Press that the actress' failed test came roughly two weeks after her release from rehab.

The Associated Press contributed to this report.