Madagascar’s Prime Minister, Olivier Mahafaly on Monday announced his resignation from office to comply with a court ruling that issued a seven-day ultimatum for the formation of a new consensus government to end a political crisis on the Indian Ocean island nation.

Last month, President Hery Rajaonarimampianina approved an election law under which the main opposition candidate, Marc Ravalomanana, could run for office. The law sparked deadly street demonstrations.

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

“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.

Rajaonarimampianina will have to consult other parties in parliament before appointing a new prime minister. His party has no lawmakers in parliament and he has until June 5 to pick the consensus prime minister as ordered by the court.

Despite the country’s large reserves of nickel, cobalt, gold, uranium and other minerals, Madagascar is one of the world’s poorest countries, having witnessed a dearth of foreign investments following a 2009 coup.