In an abrupt reversal, prosecutors announced Monday they were dropping a single felony invasion-of-privacy charge against Missouri Gov. Eric Greitens over an alleged nude photo the 44-year-old Republican took without the consent of a woman he was having an affair with. The unexpected decision to drop the charge came in the middle of jury selection and just days before the trial was set to begin.

“The prosecutor’s surprise move, announced after the third day of jury selection, came after the judge had granted a request by Greitens’ lawyers to call St. Louis Circuit Attorney Kim Gardner as a witness for the defense,” the Associated Press reports. “Greitens’ defense team has repeatedly criticized Gardner’s handling of the case, particularly her hiring of private investigator William Tisaby, whom Greitens’ lawyers have accused of perjury.” That, the Circuit Attorney’s office said, put the lead prosecutor in an impossible position of being a witness, subject to cross-examination by her own legal team, while also prosecuting the case. It “leaves the Circuit Attorney no adequate means of proceeding with this trial,” a City Attorney spokesperson said. “Therefore, the court has left the Circuit Attorney with no other legal option than to dismiss and refile this matter.”

Greitens has been besieged with allegations of disturbing sexual misconduct with his former hairdresser before winning the governor’s mansion in Nov. 2016. A special committee of statehouse legislators found the woman, who has remained anonymous, to be a credible witness, but the prosecution’s case appeared to be on shaky legal ground well before Monday’s announcement. The biggest problem? They couldn’t locate the alleged photo in question. “Months after bringing the charge against Mr. Greitens, prosecutors still had not obtained such a photo, despite searches of the governor’s cellphone and electronic cloud accounts,” according to the New York Times. “And the case had more challenges: The judge disqualified some of the prosecution’s expert witnesses. The charge itself is seldom used and difficult to prove without a photo.”

Greitens declared victory and vindication after the announcement. “This is a great victory, and it has been a long time coming,” Greitens said outside the courthouse. “This experience has been humbling, and I have emerged from it a changed man.”

This likely does not mean the end of the first-term governor’s legal and political peril. Democratic as well as Republican state lawmakers have already called for Greitens to step down and the House and Senate leadership are set to consider impeachment during a special legislative session later this week. The city attorney’s office is also expected to refile the charge through a special counsel or another attorney in the prosecutor’s office.