Lindsay Lohan COULD have avoided almost certain jail time by accepting a plea deal for lockdown rehab -- that is, if she didn't fire her lawyer who was literally on the way to the courthouse to make it happen.
Law enforcement sources tell TMZ ... the Santa Monica City Attorney -- who is prosecuting Lindsay for allegedly lying to cops after her June car crash on Pacific Coast Highway -- was willing to keep Lindsay out of jail, PROVIDED she agree to check into "lockdown rehab" for 6 months.
Sources say ... Shawn Holley -- the lawyer who has kept Lindsay out of jail -- was on her way to court Monday to meet with the prosecutor and the judge to hash out the deal. What's more, Lindsay also faces jail time for a probation violation in the jewelry heist case because she allegedly lied to cops after the crash. We're told the judge could have agreed to end both cases if Lindsay checked into rehab.
But Shawn never made it to court, because Lindsay signed her walking papers and hired a New York lawyer who was suspended in the '90s from practicing law for 5 years.
Lindsay now says she wants Shawn back. The question -- does Shawn have the stomach for another helping of Lindsay?
There's a hearing scheduled for 8:30 AM PT today. Shawn will probably show up because she's still counsel of record. If she stays on the case, prosecutors could present the deal to her, but Lindsay is making it all very difficult.