Mexico's Supreme Court unanimously ruled on Tuesday that penalizing abortion is unconstitutional.
The President of the country's highest court described the decision as a 'watershed moment' for all women, especially the most vulnerable.
The decision is a big turning point for Mexico which is the second-biggest Roman Catholic country in the world, that opposes all forms of abortion.
The ruling means that courts can no longer prosecute abortion cases, and follows the historic legalization of the right to abortion in Argentina, which took effect earlier this year.
Demonstrators took to the streets across the country celebrating the news - some women wore green bandanas to symbolize the pro-choice movement and others held placards:
Francis Pirin was in Mexico city: "We thank the judges. Millions of women living in this country and the millions of women who live in this city thank the judges for saving lives. We are going to have public policies that allow us to get secure care, on all issues of health."
There were demonstrations however, against the ruling.
Some said the focus should be on support for a woman or alternatives like adoption.
Hundreds of mostly poor Mexican women have been prosecuted for abortion, and at least several dozen remain jailed.
In the state of Coahuila, local government issued a statement saying the ruling would have retroactive effects and that any woman imprisoned for abortion should be released "immediately."
The decision is in stark contrast to the situation across the border in the U.S., where a number of states, including Texas, have restricted women's access to abortion.
Tuesday's ruling may lead American women to travel south of the border to terminate their pregnancies.