Olivier Mahafaly quits to comply with a court ruling that ordered the formation of a new consensus government.

Madagascar’s Prime Minister Olivier Mahafaly resigned on Monday to comply with a court ruling that ordered the formation of a new consensus government to end the country’s political crisis.

“I unconditionally accept this decision because I do not want to block a solution. I hand in my resignation without constraint or regret,” Mahafaly told reporters at his office in Antananarivo.

Last month, President Hery Rajaonarimampianina approved an election law under which the main opposition candidate, Marc Ravalomanana, could run for office. The law generated deadly street demonstrations on the Indian Ocean island nation.

The High Constitutional Court ordered Rajaonarimampianina to dissolve his government and appoint a new prime minister with the support of all political parties.

Presidential elections are due this year.

Madagascar is one of the world’s poorest countries, despite reserves of nickel, cobalt, gold, uranium and other minerals. A 2009 coup scared off foreign investors.

Rajaonarimampianina will have to consult other parties in Parliament before appointing a new prime minister.

His party has no legislators in Parliament and he has until June 5 to pick the consensus prime minister in compliance with the court order.