Madagascar President Hery Rajaonarimampianina has resigned ahead the November 7 presidential vote.
The Constitution requires the incumbent leader to quit office 60 days before the vote if seeking re-election.
“Since I am candidate, I have to comply with the law,” he said when addressing the nation on Friday evening.
The country’s High Constitutional Court approved his resignation.
Senate leader Mr Rivo Rakotovao will be the acting head of state until the inauguration of the next president in January.
At his last Cabinet meeting on Thursday, President Rajaonarimampianina named new army generals and appointed new ambassadors to Russia and China.
He also met the African Union High Representative for Silencing the Guns in Africa, Algerian diplomat Mr Ramtane Lamamra at State House Iavoloha.
Before announcing his resignation on Friday he held talks with the new International Monetary Fund representative in Madagascar, Mr Marc Gérard.
Mr Rajaonarimampianina is the first president to resign ahead of an election following the adoption of new electoral laws in 2010.
He faces 35 presidential aspirants among them three former head of states.
On Thursday, 16 candidates led by veteran leader Didier Ratsiraka, said they wanted the November 7 election postponed.
Mr Ratsiraka cited “secretly imported illicit weapons” and questioned the preparedness of the national institutions and the international community for the Madagascar vote.