Madagascar's constitutional court on Friday ordered the president to form a government of national union in a bid to end a prolonged political crisis.
It issued a judgement requiring President Hery Rajaonarimampianina to dissolve the present government "and proceed to the nomination of a consensus prime minister within seven days."
Madagascar has been rocked by violent protests over electoral laws that the opposition says are designed to bar their candidates from participating in elections expected this year.
The court said the composition of the unity government should proportionately reflect the outcome of the last legislative elections.
The new government will also be tasked with organising "early elections during the 2018 dry season," a period that typically runs from May to September, it said.
Since April 21, hundreds of opposition supporters have occupied a key square in the heart of the capital Antananarivo, demanding Rajaonarimampianina resign.
The row centres on new electoral legislation that the opposition says is loaded in Rajaonarimampianina's favour.
The opposition also accuses the government of trying to sideline opposition candidates out of general elections due this year.
It filed a lawsuit to the constitutional court to demand the president's ouster.
The court, in its judgement on Friday, did not give an opinion on the lawsuit. However, it ordered the high court of justice, which is mandated to rule in disputes involving current and former presidents, to meet "as soon as possible."
The crisis has triggered international concern, with the African Union, the UN and regional bloc Southern African Development Community (SADC) all dispatching envoys to try to defuse the crisis.