Mexico's Supreme Court unanimously ruled on Tuesday that penalising abortion is unconstitutional.
The decision in the world's second-biggest Roman Catholic country means that courts can no longer prosecute abortion cases, and follows the historic legalization of the right in Argentina, which took effect earlier this year.
Arturo Zaldivar, president of the Mexican Supreme Court, hailed the decision as "a watershed moment" for all women, especially the most vulnerable.
The vote by the ten judges present stemmed from a 2018 case challenging a criminal law on abortion in Coahuila, a northern Mexican state which borders Texas, which has just tightened its laws.
It also comes as a growing feminist movement has taken to the streets in Mexico to press for change.
At a demonstration in Coahuila state capital Saltillo, women wearing green bandanas to symbolize the pro-choice movement embraced and shouted "abortion is no longer a crime!"
"We're very happy that abortion has been decriminalized, and now we want it to be legal," said 26-year-old Karla Cihuatl, one of the demonstrators, who belongs to the feminist organization Frente Feminista in Saltillo.
"This step has broken the stigma a little. But I believe that we still have to change the social aspect."
With some 100 million Catholics, Mexico is the largest predominantly Catholic country after Brazil. The Catholic Church opposes all forms of abortion procedures.
Hundreds of mostly poor Mexican women have been prosecuted for abortion, while at least several dozen remain jailed.
Tuesday's vote establishes a mandatory criteria for all judges in the country, making it no longer possible to prosecute any woman who has an abortion without violating the criteria of the court and the constitution, Zaldivar said.
Coahuila's state government issued a statement saying the ruling would have retroactive effects and that any woman imprisoned for abortion should be released "immediately."
A number of US states have moved to restrict access to abortion, particularly Texas, which last week enacted a ban on the procedure after the first six weeks of pregnancy, (approximately when a heartbeat is detected), when the US Supreme Court declined to intervene.
The Mexican ruling may lead to US women in states such as Texas deciding to travel south of the border to terminate their pregnancies.
In July, the state of Veracruz became just the fourth of Mexico's 32 regions to decriminalize abortion.
Mexico's leftist President Andres Manuel Lopez Obrador has carefully avoided taking a stand on the matter, as he did again on Tuesday morning in the run-up to the ruling.
When asked at a news conference for his opinion on abortion, he sidestepped the question, saying it was up to the court.
"Due my presidential office, I can't expose myself to wear and tear, so I have to look after myself, and this is quite a controversial issue," he said.
During his winning 2018 election campaign, he forged an alliance with a small political party founded by Christian conservatives known for their strong opposition to abortion.
By contrast, Foreign Minister Marcelo Ebrard, who was mayor of Mexico City when the capital legalized abortion in 2007, breaking new ground for the country, celebrated the court ruling on Twitter as a "great day for the rights of women."
"What advances there have been in progressive causes in our country!!!" wrote Ebrard, one of the leading contenders to succeed Lopez Obrador when his six-year term ends in 2024. "I'm really delighted!!"