Slideshow ( 5 images )

SANTIAGO (Reuters) - Chile’s senate narrowly passed a bill on Wednesday to legalize abortion in certain cases, in a win for President Michelle Bachelet’s center-left coalition and for rights groups that have campaigned for years against the country’s strict ban.

After a long and sometimes fractious overnight debate, the senate voted to legalize abortion when a woman’s life is in danger, when a fetus is unviable, and when a pregnancy results from rape.

Chile is one of only a handful of countries worldwide where abortion is illegal without exception. The ban was put in place during the closing days of Augusto Pinochet’s 1973-1990 dictatorship, and Bachelet pledged reform when she took office for the second time in 2014.

The bill will now be returned to Chile’s lower house to be reconciled with a version passed there. That is expected to happen within the week, allowing it to become law.

Senate approval had been seen as the biggest hurdle for the measure, given opposition from some Christian Democrats within Bachelet’s own coalition, as well as lawmakers from the right-wing Chile Vamos bloc.

“It’s a historic morning,” Bachelet said in front of the presidential palace after the bill passed. “The senate approved depenalizing abortion in three cases, which means we can be a country where women can make the best decision possible when faced with such situations.”

Although Chile is seen as one of Latin America’s more socially conservative countries and the Roman Catholic Church retains significant influence, polls show around 70 percent of Chileans favor the easing the abortion ban.

However, the conservative opposition has pledged to challenge the measure in the courts.

“It has been a sad day for Chile,” said Jacqueline van Rysselberghe, a senator for the far-right UDI party. “We are going to take it to the constitutional tribunal (to try to block it).”