Chile's Congress has approved a bill that would legalize abortion in limited circumstances—ending the country's status as the last in South America to ban all abortions.

The measure approved by lawmakers late Wednesday allows abortions when a mother's life is in danger, when the fetus is not viable and in cases of rape.

President Michelle Bachelet backs the measure and has said she would sign it into law. But it still needs to be approved by Chile's Constitutional Tribunal.

Opposition senators argue the measure violates the constitution.

Chile legalized abortion for medical reasons in 1931. But abortion was banned under all circumstances during the 1973-1990 dictatorship of Gen. Augusto Pinochet.