KINSHASA (Reuters) - Political rivals in Democratic Republic of Congo neared a deal on Saturday for President Joseph Kabila to leave power in 2017 after dozens of people were killed during protests this week at the end of his mandate.

FILE PHOTO - Democratic Republic of Congo's President Joseph Kabila attends the signing ceremony of the Peace, Security and Cooperation Framework for the Democratic Republic of Congo and the Great Lakes, at the African Union Headquarters in Addis Ababa, Ethiopia February 24, 2013. REUTERS/Tiksa Negeri/File Photo

Under the agreement, elections would be held next year and Kabila, who took power in Africa’s fourth most populous country after his father was assassinated in 2001, would agree not to change the constitution to run for a third term.

Roman Catholic bishops who have mediated during weeks of talks were upbeat about reaching a deal in time for a planned signing ceremony on Friday, but Congo’s main opposition bloc warned that several “significant” differences remained.

“We have finished practically 95 percent of the work,” Catholic Bishops Conference president Marcel Utembi told reporters. “There remains a short way to go.”

Divisions persisted over whether the prime minister will come from the main opposition bloc and on the composition of the electoral commission, which the opposition accuses of pro-government bias.

“If the divergences are not bridged, it will be difficult to sign this accord,” opposition leader Jean Marc Kabund told reporters.

Kabila, whose representatives participated in the talks, did not comment.

At least 40 people were killed this week in a crackdown by security forces against demonstrators who blew whistles and banged pots and pans in protests demanding Kabila leave office, according to the United Nations.

Kabila’s critics accuse him of deliberately postponing the presidential election that was due last month in order to cling to power beyond the end of his constitutional mandate.

The government say the delay was due to difficulties registering millions of voters and the constitutional court ruled in May that Kabila could stay in office until his successor is elected.

Mineral-rich Congo has not had a peaceful power transition since independence in 1960, and Church negotiators have billed the talks as an attempt to stop the country sliding back into war.

Millions of people died in regional conflicts between 1996 and 2003 and Pope Francis has called for a peaceful solution to the current standoff.

The last day of the talks between the ruling coalition and opposition parties began at 11 a.m. local time (5.00 a.m. ET) after negotiations went through the night.

Remaining issues are to be resolved in small groups with the support of the church’s secretariate while the bishops return to their dioceses for Christmas, Utembi said.