Haitian leaders have signed an agreement to install a caretaker government as President Michel Martelly steps down amid violent protests and with no successor in sight.

Under Saturday's deal, the interim government will run for four months before holding presidential elections by April 24 and transferring power to the winner in the following month.

"Despite this agreement, we will need to continue to remain vigilant because there are people who won't agree," Martelly, whose term comes to end on Sunday, said at an event with foreign diplomats at the palace.

A presidential runoff due to be held in January 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.

The Haitian capital, Port-au-Prince, has since then witnessed daily protests by both opposition and government supporters culminating in the lynching of a former soldier during a march on Friday.

The main challenge for the caretaker government will be to overcome deep disagreements about how the election should be organised and which candidates can participate.

In 2004, when the elected president Jean-Bertrand Aristide was toppled in a coup, it took the transitional government two years to organise elections.