(CNN) -- Four current and former leaders of Madagascar have struck a power-sharing deal, ending months of political wrangling that has rocked the island nation off the east coast of Africa, the United Nations said.
The Saturday agreement was made among ousted President Marc Ravalomanana, current President Andry Rajoelina, who took power in March, and former presidents Didier Ratsiraka and Albert Zafy.
Under the deal, Rajoelina will serve as president along with two new co-presidents.
Ravalomanana had pledged to reject any accord that allowed his successor to be the sole leader of the country.
It was not immediately clear how power will be divided among the leaders.
Rajoelina, 35, a former disc jockey, ousted Ravalomanana with the help of the military in March. The international community has not recognized him as president, and the United States condemned the toppling as a coup. U.S. officials deemed it "unconstitutional and undemocratic."
The four leaders reached another separate power-sharing deal in August, but disagreed on the composition of a transitional government.
In a statement Saturday, United Nations chief Ban Ki-moon urged the leaders to set up the unity government as soon as possible this time around, and pledged to support Madagascar through the transition.
Months of political turmoil have affected the economy of the mineral-rich Indian Ocean island.