An Iowa judge cited the courthouse arrest of a drunken prosecutor in dismissing charges against a man accused of sexually assaulting a 13-year-old boy.

Judge Marti Mertz issued the ruling Monday and chastised Clarke County Attorney Michelle Rivera. The prosecutor's unavailability at a recent hearing in the case "was the finale following unexplained periods of inactivity and lack of responsiveness" since the man's arrest more than a year ago, the judge said.

A sheriff's deputy arrested Rivera for being drunk in an Osceola courtroom on Oct. 18, just moments before the man was scheduled to enter a new plea and be sentenced in the case.

The man later sought a dismissal because he hadn't been tried within a year of his arraignment. He was initially charged with sex assault and telephone dissemination of obscene material to a minor. Investigators say he admitted engaging in sex act with a minor in August 2017.

The state can't refile the same charges against the man, said Mark Pennington, a former Polk County prosecutor not involved in the case

"Everybody should be upset about it," Pennington said. "That's why you have to hold elected officials, including county attorneys, to a high standard."

Drake University law professor Robert Rigg, a criminal law expert, said there are options if the state wants to pursue charges.

Clarke County prosecutors could attempt to file different charges, such as lascivious acts against a child. Or they could allow federal prosecutors to file their separate charges to get around the double-jeopardy protections the man now has at the state level.

"He may end up winning the battle and losing the war," Rigg said.

A spokesman for the Iowa Attorney General's office said no one at the county level has sought their help in the case.

Rivera and her attorney didn't immediately return messages from The Associated Press on Tuesday seeking comment about the case. Attempts by the AP to reach the victim's parents and their attorney were unsuccessful.

Rivera pleaded guilty in the courthouse intoxication incident and was fined $65.

The man's attorney, Marshall Orsini, told television station KCCI that his client's release from jail was long overdue.

"If the defendant is not put on trial (and) is not tried within a year, you have the potential to have that case dismissed, and that's what happened here," Orsini said.

Rivera lost her re-election bid in November. She was arrested again last week in Osceola on charges of operating a vehicle while intoxicated and child endangerment. According to court documents, an officer said Rivera was intoxicated when she dropped her daughter off at a day care. A hearing on the new charges is set for Thursday.