Mexico's Supreme Court has ruled that soldiers accused of human rights abuses against civilians should be tried in civilian - not military - courts.
Rights groups say violations by army personnel have risen sharply since troops were deployed against the drug gangs in late 2006.
Until now, soldiers have been tried by military tribunals.
Activists hailed the decision but highlighted shortcomings in Mexico's civilian courts.
The Supreme Court set out restrictions on the extent of the military code of justice in Mexico.
"Whenever a civilian's human rights have been violated by the armed forces, jurisdiction will be in civil courts," said Supreme Court Justice Arturo Zaldivar.
The justices ruled that "Mexican judges should apply the criteria of restricting military justice in future cases", a court statement said.
Over the last few years, allegations of abuses by soldiers have become more frequent. In many cities in Mexico, the army has policing powers and direct contact with the population.
Soldiers have been accused of opening fire on civilians at checkpoints in areas where drug gangs operate, and of carrying out illegal arrests and searches.
The National Human Rights Commission says it has received more than 5,000 complaints about alleged abuses by the military since President Felipe Calderon launched his offensive against the drug gangs in December 2006.
Activists say few soldiers have been prosecuted for abuses and even fewer convicted by the military courts.
Human rights groups broadly welcomed Tuesday's decision, while saying they would watch to see how it is implemented.
"We like it, and we hope that it begins to be applied soon," human rights lawyer Andres Diaz told the Associated Press.
Alberto Herrera, head of Amnesty International in Mexico, said that this was a first step but that "scandalous impunity" was not only found in the military but the civilian judiciary.
"We can transfer all the cases currently in military courts to civilian courts, but if civilian justice doesn't function, this won't amount to much," he told Mexican media.
The government said it would work to implement the Supreme Court's findings.
A statement said efforts would continue to strengthen military courts and thereby military discipline, "an indispensable element to allow the armed forces to fulfil the duties assigned to them".
The Inter-American Court of Human Rights called last year for Mexico to reform its military justice system.
This was based on the case of a left-wing activist, Rosendo Radilla, who was detained in the 1970s by the army and never seen again.