On Monday, Illinois State Rep. La Shawn Ford walked out of a Chicago courtroom smiling, with all 17 felony counts against him dismissed.

In a shocking deal with federal prosecutors, Ford pleaded guilty to 1 misdemeanor charge of tax fraud that will allow him to remain in public office and likely keep him out of prison.

It is rare for the U.S. Attorney’s office, which charged Ford in 2012 with 17 serious felony counts connected to an alleged bank fraud, to make such a deal.

From the start, La Shawn Ford, a West Side Democrat, claimed the charges against him were bogus and motivated by race.

Things took a surprising turn on Monday when he pleaded guilty to a single count of delivering a false federal tax return and admitting to U.S. District Judge Rebecca Pallmeyer that he dodged around $3,700 in taxes by overstating the amount he spent to rehab a West Side home.

Ford, 41, who invests in real estate through his business Ford Desired Real Estate, Inc, had originally been accused of fraudulently obtaining a $500,000 increase and a 2-year extension on a line of credit from a failed bank called ShoreBank and making false statements to gain multiple advances.

The feds alleged in 2012 that he got the loans to rehabilitate specific buildings, used them for unrelated expenses, including, car loans, credit cards, mortgages, payments to a casino in Hammond, Ind., and even for his 2006 campaign for Illinois state representative.

All those charges are now gone, and though Ford faces a possible jail sentence of up to 1-year when he is sentenced in November, as a first-time offender he is far more likely to receive probation and a fine.

The surprise plea deal on Monday comes less than 2 months after Ford’s lawyer accused prosecutors of unfairly targeting Ford because he is a black elected official — a charge they angrily denied.

But evidence from a separate civil case showed that white defendants who engaged in identical behavior to Ford’s at ShoreBank were not criminally charged.

U.S. Attorney spokesman Randall Samborn refused to comment Monday on why the feds agreed to such a good deal for Ford.

The resolution of the case means that there is just one pending case against a politician in Chicago’s federal court, so often a graveyard for political careers.

Former State Rep. Keith Farnham, charged with possessing child pornography earlier this year, is the only politician who has been charged since Zach Fardon became U.S. Attorney in October.