PORT-AU-PRINCE (Reuters) - Haiti’s outgoing President Michel Martelly has reached an agreement with parliament to form a caretaker government when he leaves power this weekend without an elected successor, in a step that could calm violent protests rocking the capital.

Outgoing Haiti's President Michel Martelly looks outside of the Ministry of Interior during the inauguration of the new building in Port-au-Prince, Haiti, February 4, 2016. REUTERS/Andres Martinez Casares

Under the agreement due to be signed later on Saturday, parliament will elect an interim president for a four-month term, said the Organisation of American States, which helped broker the deal among deeply divided politicians in the Caribbean nation.

A presidential runoff due to be held last month was scrapped after opposition candidate Jude Celestin threatened to boycott the vote over allegations of fraud in the first round, and protesters took to the streets in force.

Martelly is set to leave office on Sunday.

The interim president’s primary job will be to quickly hold a presidential election, which under the deal, should happen on April 24, with the new elected leader taking power in May.

Port-au-Prince has seen almost daily protests by both opposition and government supporters since January, culminating in the lynching of a former soldier during a march on Friday.

Any caretaker government will have to overcome deep disagreements about how the election should be organized and which candidates can participate, since many opposition politicians are convinced the first round vote was riddled with fraud that favored ruling party candidate Jovenel Moise.

The government denies the allegations.

Haiti has struggled to build a stable democracy since the end of the brutal Duvalier family regime in the 1980s. The impoverished country has had a chequered experience with caretaker governments, which in the past have lingered longer than expected.

When Haiti was left without an elected president after Jean-Bertrand Aristide was toppled in a 2004 coup, it took the transitional administration two years to organize elections.