Mexico's Supreme Court has ruled that criminal penalties for terminating pregnancies are unconstitutional.
The ruling, for the northern state of Coahuila, prevents women from being prosecuted for getting an abortion.
Abortion is currently severely restricted in all but four of the country's states.
Supreme Court Justice Luis Maria Aguilar described the move as a "historic step for the rights of women".
On Tuesday, the court ordered the state of Coahuila to remove sanctions for abortion from its criminal code.
The decision could pave the way for the decriminalisation of abortions across the country.
Currently, abortion is only legal in a handful of states, except in cases of rape or where the mother's life is in danger.
A judicial source said the ruling will affect the whole of Mexico, allowing women in states where abortion is criminalised to undergo the procedure with a judge's order.
The Information Group on Reproductive Choice (GIRE), which campaigns for abortion rights, described the decision as "historic".
"We hope that throughout the country women and people with the ability to carry a child have the conditions and freedom to determine their reproductive destiny," it said.
Coahuila borders the US state of Texas, where the Supreme Court allowed a state law banning all abortions after six weeks of pregnancy.
The ruling could open up avenues for people from Texas seeking legal abortions.
The decision to decriminalise abortion in what is Latin America's second-largest Catholic nation might appear surprising.
However, the debate in Mexico has been gradually moving towards removing the illegality for some time.
High profile protests by feminist and women's rights campaigners have underlined the need for greater reproductive rights in Mexico.
Specifically, the Supreme Court was asked to rule on a law in the northern state of Coahuila which punishes women who have illegal abortions with jail terms of up to three years.
The 11 Supreme Court judges unanimously voted to decriminalise abortion in that state, and under Mexican law, it will now apply to all the other states in the country.
It is likely to take some time to be applied across the nation, but in effect the decision provides each state with a roadmap towards new legislation.
Furthermore, it should mean that women who were jailed for having abortions will be immediately released.
The decision is likely to anger more conservative politicians in Mexico and the Catholic Church. However, the church's influence has been waning in recent years and the government considers itself staunchly secular.