A federal judge on Thursday upheld former District of Columbia Mayor Marion Barry's probation in a criminal tax case, meaning the longtime politician will avoid the possibility of prison.

Barry, 71, and now on the D.C. Council, pleaded guilty in 2005 to misdemeanor charges for failing to file tax returns from 1999 to 2004. As part of his plea bargain, he agreed to file future federal and local tax returns annually.

But prosecutors accused Barry of missing deadlines for filing federal and D.C. tax returns for 2005. They argued in court filings that Barry "has not acted like a person who has been given the opportunity of probation and should not be treated like one."

In deciding to uphold Barry's probation, Magistrate Judge Deborah A. Robinson ruled that prosecutors did not prove that Barry willfully failed to file his returns even if he was aware that he missed the deadline.

"It's good to have a good God, a good lawyer and a good judge," Barry said. "That's what we had in this case. Maybe this might be the last time they bring these frivolous cases."

Last week, Barry was acquitted of drunken driving and other offenses stemming from an incident last year in which he was pulled over by Secret Service agents near the White House.

Barry served four terms as mayor. In his third term, he was videotaped in 1990 in a hotel room smoking crack cocaine in an FBI sting. He served a six-month prison sentence and in 1994 regained the mayor's office for another four-year term.