US District Judge Cameron McGowan Currie ruled on Monday that the prosecutor, Lindsey Halligan, was illegally appointed.
The judge agreed that Halligan, the US Attorney for the Eastern District of Virginia, had exceeded the 120-day interim period allowed for her position without Senate confirmation or judicial approval.
Halligan, a former White House aide, had no prior experience as a prosecutor before bringing these cases.
This decision undercuts President Donald Trump's efforts to prosecute his political adversaries.