Madagascar's prime minister announced his resignation to resolve a political crisis sparked by controversial electoral reforms.

Madagascar's Prime Minister Olivier Mahafaly Solonandrasana on Monday announced his resignation in the first step towards the naming of a "consensus" premier to resolve a political crisis sparked by controversial electoral reforms.

Madagascar has been rocked by protests that initially sought to oppose new laws the opposition said were crafted to bar their candidates from participating in elections planned for later this year.

The Constitutional Court has ordered Madagascar President Hery Rajaonarimampianina to form a government of national unity with a "consensus prime minister" to avert a full-blown crisis.

Since April 21, hundreds of opposition supporters have occupied the capital Antananarivo's May 13 square, initially to protest the president's proposed electoral reform package.

But after those proposals were overturned by the courts, the protests became a full-blown movement to oust Madagascar President.

On Monday Madagascar President appeared at a press conference alongside the former prime minister and confirmed that although the government had stepped down, it would keep its powers for a transitional period.