A judge in the US state of Georgia overseeing Donald Trump's election interference case has ruled the prosecutor who brought the charges can remain on the case if the special prosecutor she appointed steps aside.
Mr Trump and his co-defendants had been seeking to have Fulton County District Attorney Fani Willis removed following revelations that she had a romantic relationship with Nathan Wade.
The ruling, by Judge Scott McAfee, is a blow to the former US president and Republican candidate to challenge Democratic President Joe Biden later this year.
The judge's decision caps a tumultuous two months for Ms Willis, whose relationship with Mr Wade was revealed in a January court filing by a co-defendant of Mr Trump.
It also ends three months of contentious litigation and evidentiary hearings over the relationship that effectively paused the rest of the case, though a trial date has yet to be set.
Defence lawyers said the relationship posed a conflict of interest and improperly enriched Ms Willis and Mr Wade, who holidayed together while he was drawing a government salary.
Judge McAfree found the relationship did not pose a conflict of interest but said it created "a significant appearance of impropriety" that required either Ms Willis or Mr Wade to step aside.
Mr Trump's lawyer Steve Sadow said in a statement that he respected the ruling but believed it did "not afford appropriate significance to the prosecutorial misconduct of Willis and Wade".
Ms Willis and Mr Wade testified that their relationship did not begin until after he was hired.
Prosecutors argued the affair was irrelevant because it did not harm the defendants.
Defence lawyers accused the prosecutors of lying to the court, saying the relationship began before Mr Wade was hired.
In court papers filed on 23 February, Mr Trump's lawyer cited location data from Mr Wade's mobile phone suggesting he made numerous late-night visits to Ms Willis' home before she appointed him.
The former president is accused of illegally pressuring officials in Georgia to overturn his loss to Joe Biden in the state in the 2020 presidential election.
He has pleaded not guilty in the four criminal cases he faces and has sought - unsuccessfully - to delay the start of the trials until after this November's vote.