PORT-AU-PRINCE (Reuters) - Michel Martelly stepped down as Haitian president on Sunday, leaving a deeply divided country in the hands of a disputed interim government, while the first day of Carnival celebrations was cancelled as violent protests erupted.

The mood was grim on what should have been a festive day that would have marked a newly elected president, as well as the 30th anniversary of the fall of the Duvalier dictatorship and the start of the Caribbean country’s Carnival.

Riot police clashed with protesters and Martelly handed back the presidential sash without anyone to succeed him.

Weeks of unrest set off by a first-round election that critics say was fraudulent meant the impoverished nation was unable to hold a runoff to chose a new president before Martelly’s term ended.

Under a last-minute agreement welcomed by Washington and other foreign powers, parliament is due to choose a temporary president in the next few days. Elections are set for April 24 and the winner would take office in May.

But there is a major catch. A group of eight losing candidates from the first round rejected the notion of parliament choosing the interim president, and called instead for a Supreme Court judge to lead the process.

The group, which includes the opposition candidate for the runoff, Jude Celestin, believes the parliamentarians, who were elected in the same flawed October first round, do not have the legitimacy to oversee the interim government or a new vote.

Slideshow ( 3 images )

“This alleged agreement attempts to validate the 2015 elections as if they were regular, regardless of popular protests that resulted in numerous casualties,” spokesman Samuel Madistin said in a statement.

Madistin said the agreement reflected the position of part of the international community and Haiti’s ruling class.

Opposition protesters and police clashed again in downtown Port-au-Prince on Sunday in the area that hosts the capital’s heavily attended and raucous annual Mardi Gras celebrations, with some groups trying to attack Carnival stages.

The Carnival organising committee called off the first day of the festival, citing the unrest. Two top musical groups had already pulled out, with bandleader Roberto Martino saying his group, T-Vice, might not take part at all.

Martelly formally left office during a ceremony at the national assembly, guarded outside by U.N. troops and riot police. Assembly President Jocelerme Privert called for a “truce” to allow enough stability to organise the elections, already postponed three times, most recently in January.

Any interim government will have to overcome strong disagreements about which candidates can participate, since many are convinced the first round unfairly favoured ruling party candidate Jovenel Moise.

Martelly’s government denied any wrongdoing.