A 34-year-old former DJ has become the youngest serving head of state in Africa after months of violent protests finally bulldozed Madagascar's president out of office.

Andry Rajoelina was confirmed as the "serving president of the republic" by the constitutional court today, despite being too young for the top job under the Indian Ocean island's legal system.

It marked a humiliating departure for his immediate predecessor Marc Ravalomanana who was all-but forced to resign after a power struggle that had threatened to drag the troubled former French colony into a bloody civil war.

Power had been visibly ebbing from Mr Ravalonmanana in recent days and in his last 24 hours in office the 59 year old, saw the army storm his offices in the capital while he watched powerless from his residence on the outskirts of the city guarded by a rag-tag coterie of his remaining supporters.

Yesterday began with the opposition announcing that it had accepted the resignation of eight of his cabinet ministers, and then the President dropped his rhetoric of fighting to the death and resigned.

Even as he declared time on his second term in office, he sought to delay the coronation of his rival, Mr Rajoelina, who is still six years short of the constitutionally stipulated minimum age for Madagascar's highest office. "After right reflection, I have decided to dissolve the government and transfer power so that a military government can be put in place," Mr Ravalomanana said in a statement on national radio. But his attempt to hand the government to the country's most senior military officer, Vice-Admiral Hyppolite Ramaroson, appeared to be discounted by both the army and the opposition.

Mr Rajoelina, who stirred popular unrest against the President while he was mayor of the capital city, wasted little time, marching into the President's sacked offices and declaring himself in charge. "It is the path Madagascar must take," said Mr Rajoelina, who made his money in advertising. It is a path that the military, including Vice-Admiral Ramaroson, was expected to endorse last night.

Mr Rajoelina also called the recently resigned president a "dictator" who runs Madagascar as a private business. Many see the hand of the powerful former president Didier Ratsiraka, 71, behind the young ex-mayor and the veteran politician could yet re-emerge as a contender in fresh elections.

Waves of protests from December paralysed the capital, while as many as 135 people were killed in clashes between demonstrators and security forces. The army even mutinied last week, declaring its support for Mr Rajoelina.

While some diplomats on the island and foreign officials expressed relief at the peaceful conclusion of the power struggle, others are concerned at the manner of Mr Ravalomanana's overthrow. "The use of violence as a means to short-circuit the constitutional process is unacceptable," said Javier Solana, the EU's foreign policy chief.

The instability could be the product of outside efforts to secure Madagascar's mineral wealth. Some analysts point to the recent visit by the Chinese President, Hu Jintao; his country is involved in projects from iron ore to possibly arranging naval port facilities, and the island could factor into China's naval expansion strategy.

Mark Schroeder, at the global strategists Stratfor, added: "Madagascar has tremendous reserves of crude oil sands which have not yet been fully explored."

But if Mr Rajoelina does not swiftly deliver an upturn for Madagascar's impoverished majority he could also find himself on the receiving end of street protests.