Lindsay Lohan was saved from almost certain arrest by the lawyer she once stiffed and fired ... this according to the judge.
TMZ has learned ... Shawn Holley snuck into court this morning, along with prosecutors, where the judge formally 86'd attorney Mark Heller from the case and announced Holley would be Lindsay's new lawyer.
Judge Jim Dabney told Shawn, "You snatched her from the precipice." Translation: The judge was about to issue an arrest warrant because Lindsay was a rehab no-show but Shawn stepped in and saved the day.
Holley told the judge Lindsay was safely ensconced at Betty Ford. Prosecutors voiced concern that the rehab joint only offers 30-day programs, which would mean Lindsay would repeat the same program 3 times to fulfill her 90-day sentence. But Holley said there were longer programs that would not be repetitive.
The judge seemed fine with Betty Ford and said there's no need for another hearing unless prosecutors have a problem with the facility. Law enforcement sources tell TMZ ... prosecutors are currently investigating Betty Ford to determine if the facility is suitable.
A big issue is whether Lindsay will be able to leave and/or sneak out of the facility. You'll recall during her 2010 stay at Betty Ford she left the facility several times. That's because she was staying in the residential part of the facility. Sources tell us Lindsay will stay in the hospital section for her entire stay so leaving won't be an option -- at least that's the plan.