After a marathon two-day debate, marked by angry exchanges inside the House and noisy protests outside, the Irish Parliament on Friday passed a watered-down legislation allowing abortion under limited circumstances.

It would now go to the Upper House for a final vote where it is expected to have an easier ride as it is controlled by the ruling Fine Gael party.

The long-awaited legislation follows widespread outrage over the death of Savita Halappanavar, a young Indian dentist, who died in an Irish hospital last October after being refused abortion despite apparent risk to her life. An inquiry found that she could have been saved if doctors had agreed to her request for termination.

The Protection of Life During Pregnancy Bill 2013, adopted by a narrow majority of just four votes, would permit abortion if the mother’s life is in danger. It would also extend to women who are deemed suicidal if refused abortion.

In effect, the bill simply gives effect to a 1992 Supreme Court ruling allowing doctors to perform abortion to save a mother’s life. Successive governments failed to legislate on it because of fierce opposition from the aggressive pro-life lobby.

The legislation, which caused a deep rift in the governing coalition with one Minister voting against it and later resigning from the Cabinet, left both sides dissatisfied with pro-abortion campaigners complaining that it did not go far enough and the opponents warning that it would open “flood-gates” to women seeking termination.