MEXICO CITY (AP) — An appeals court ruling is threatening to derail Mexico's effort to prosecute suspects in one of its most notorious crimes of recent years: the disappearance and presumed murder of 43 students in Guerrero state.

The injunction, issued late last year but not yet publicized, orders the state judge overseeing the case to correct flaws in its case against 22 police officers who are accused of killing four people on the night the students vanished.

The case of the 43 teachers' college students is one of the most widely protested and troubling examples of human rights abuses in Mexico's recent history — one that has shaken faith in all levels of government.

Federal prosecutors say the local police killed several people, rounded up the students and handed them over to a drug cartel, which killed them, possibly suspecting they were linked to rivals.

But the bodies have not been found, the motives are in dispute and outside investigators have suggested that state and perhaps even federal agents may have played a role in the disappearances.

The injunction, which came in response to an appeal of the charges by lawyers for the 22 police officers, found prosecutorial errors including inconsistent testimony and scant evidence. If those can't be fixed, the case would be thrown out.

The appellate ruling shows the entire case was built on "foundations of mud," said Sayuri Herrera, the lawyer for the family of Julio Cesar Mondragon, a 22-year-old student who was found dead in the city of Iguala on Sept. 27, 2014, the morning after the disappearances. There were signs of torture on his body and the skin was flayed from his face.

"Nearly all the prosecutions underway could fall apart," Herrera said, "because nearly all were carried out, at least at the beginning, by the same people" — Guerrero state prosecutors.

The case involves four of the six confirmed killings that night: Mondragon; Blanca Montiel, 40, who was cut down by gunfire as she rode in a taxi; David Jose Garcia Evangelista, a 15-year old boy traveling on a bus with his soccer team; and Victor Manuel Lugo Ortiz, the driver of the bus.

The ruling, to which The Associated Press gained access, argues that state prosecutors "did not carry out an ample and diligent analysis" of the events — echoing criticism by a team of international experts authorized by the government to review federal officials' investigation of the disappearances.

The injunction complains that the case against the officers relies on testimony implicating the same people in different attacks in different places at roughly the same time. It says there's no explanation of exactly who did what, and no proof linking individual suspects to specific crimes.

Guerrero state prosecutors did not respond to multiple phone calls and messages seeking comment. The state-level appellate decision is being reviewed by a higher, federal court as is allowed under Mexican law.

While the killings are the province of local courts, investigation of the 43 students' disappearance is being carried out by federal prosecutors.

The federal prosecutor's office told the AP that it believes the appellate ruling "will not affect" its case because the decision doesn't involve federal statutes involved in the disappearances: kidnapping and organized crime.

But an investigator involved in the case, who was not authorized to discuss it and spoke on condition of anonymity, acknowledged that the federal investigation has "the same problems."

The 22 suspects are also linked to the students' disappearances, and the warrants for most of the rest of those detained in the federal case — more than 100 suspects — were issued by the same authorities whose work was called into question by the appeals judge.

The investigator doubted that the local court in Iguala will be able to produce the kind of evidence demanded by the appeals judge, given mistakes in gathering evidence from an incident that took place 15 months ago. He also noted that some suspects in the disappearances claim to have been tortured, and that could invalidate prosecutions if confirmed.

A group of experts reviewing the case for the Inter-American Commission on Human Rights declined to discuss the recent injunction. But in September, they said the federal case was plagued by fundamental errors such as confusion over the time and place of events and the mishandling of ballistic evidence.

In a scathing report, they picked apart the official account of events, arguing it was impossible for the 43 students to have been incinerated in a trash dump as prosecutors contended, and alleged obstruction of justice by officials at various levels of government.

Federal prosecutors promised to take the experts' recommendations into account and install a new investigative team.

Jose Miguel Vivanco, Americas director for Human Rights Watch, said the appellate ruling was the result "chronic incompetence of agents of justice who do not respect minimum standards for a professional legal investigation."

"If the negligent conduct by these officials goes unpunished and there are no sanctions, it will be difficult for Mexico to show improvement on human rights," Vivanco said.

Herrera, the Mondragon family lawyer, said the state has three options: the original judge could rework the case with better evidence, step aside in favor of federal courts or exonerate the defendants — though they would not immediately walk free because they are also suspects in the federal probe.

In any case, Herrera said, it's like "starting from zero."