Mexico City legislators voted 46 to 19 to pass a leftist-sponsored bill allowing women to seek abortion within the first trimester at city hospitals and private abortion clinics.
Girls under 18 need parental consent.
The ban remains elsewhere in the world's second-largest Catholic nation, where abortions are allowed only in extreme cases such as rape, severe birth defects or where the woman's life is at risk.
Anti-abortion activists are planning to appeal the law to the Supreme Court.
Mexicans are sharply divided over the bill and have staged emotional protests.
Pope Benedict sent a letter last week urging Mexican bishops to oppose the bill.
But supporters welcomed the move saying it will prevent thousands of mostly poor women who resort to abortions in unhygienic backstreet clinics from dying each year.
"We don't want any more women to die in clandestine abortions," Agustin Guerrero, a leftist local deputy, said.
Jorge Diaz Cuervo, a city legislator and a social democrat who voted for the bill, said: "Decriminalising abortion is a historic triumph, a triumph of the left."
Martha Micher, director of the Mexico City government's Women's Institute, said an estimated 200,000 women have illegal abortions each year in Mexico based on the number who show up at hospitals later seeking treatment for complications.
Botched abortions using herbal remedies, black-market medications and quasi-medical procedures kill about 1,500 women each year and are the third-leading cause of death for pregnant women in the capital, she added.
Under the Mexico City law, abortion after 12 weeks of pregnancy is punishable by three to six months in jail.
Church leaders have threatened to excommunicate leftist deputies, mostly from the Democratic Revolution party, who voted in favour of lifting the abortion ban in the capital.
Last Mod: 25 Nisan 2007, 17:21
On Monday, the Vatican's second-highest ranking doctrinal official, Archbishop Angelo Amato, denounced abortion and euthanasia as "terrorism with a human face".
The city is dominated by Democratic Revolution party legislators, at odds with the conservative National Action party led by Felipe Calderon, the president, who opposes abortion.
"We go to great lengths to protect [sea] turtle eggs,'' Paula Soto, a city legislator from Calderon's party said.
"Lucky turtles! It appears they have more people willing to defend them than some unborn children."
Riot police kept rival groups of rowdy demonstrators apart outside the Mexico City's assembly building where weeping anti-abortion protesters played tape recordings of babies crying and carried tiny white coffins.
Cuba, Guyana and Puerto Rico have similar legislation. Nicaragua, El Salvador and Chile ban abortions completely.