MEXICO CITY – A Guatemalan judge on Thursday annulled the genocide trial against the former dictator Gen. Efraín Ríos Montt, a stunning ruling that could force prosecutors to begin the case all over again.

The decision, by Judge Carol Patricia Flores, brought an abrupt halt to a trial that has become a test case of Guatemala’s judicial system and has reopened painful memories of the bloodiest chapter in the country’s long-running civil war.

Judge Flores was involved in the case early on but was not the trial judge hearing the evidence. Her ruling appeared to be based on a Supreme Court decision first to recuse her, in late 2011, and then to reinstate her a few months later. But the judge said Thursday that the reinstatement decision was never communicated to lower courts, which she said nullified all the court proceedings related to the case, including the decision to send it to trial.

“I want to be clear that I am not ruling at my whim,” she said.

The trial judge, Yasmin Barrios, summoned the defense and the prosecution to her courtroom on Friday morning.