Top generals installed a bitter rival of Madagascar's former president after rejecting the fallen leader's attempt to cede power to them. Marc Ravalomanana stepped down Tuesday as the Indian Ocean island nation's president, intending to transfer rule to a military directorate. But in a ceremony broadcast from a military camp in the capital, Vice-Admiral Hyppolite Rarison Ramaroson said the military instead was installing opposition leader Andry Rajoelina. For months, Rajoelina - a disc jockey turned broadcasting magnate who had been mayor of Antananarivo, the capital - has been leading anti-government rallies and pressing Ravalomanana to step down. Some protests have led to deadly clashes. He accused Ravalomanana of misspending public funds and undermining democracy in Madagascar - an impoverished nation off the coast of southeastern Africa known for both its natural beauty and its political instability. Over the weekend, Rajoelina declared himself president of a transitional government and promised new presidential elections within two years. On Monday, he called on the army to arrest the president, but soldiers refused. After weeks of insisting he would never resign, Ravalomanana announced Tuesday afternoon he was ceding control to the military. Almost as he spoke, Rajoelina was parading triumphantly through the capital surrounded by armed soldiers and an adoring crowd after seizing control of one of the city's presidential palaces. Rajoelina told the French television station LCI he had the support of "soldiers, government workers, unions, that is to say all the country's key groups." "Power belongs to the people," Rajoelina said. "The people give power, the people can take it back." Norbert Lala Ratsirahonana, former chief of the constitutional court, acted as master of ceremonies for the military announcement, lending the move legitimacy even though Rajoelina, at 34, is too young to be president according to the constitution. Ravalomanana claimed his rival sought power by unconstitutional means. Ravalomanana's rags-to-riches tale - he started out selling ice cream from a bicycle - was once a source of popularity. But Rajoelina, tapping into the deep dissatisfaction of Madagascar's impoverished majority, portrayed Ravalomanana as interested mostly in enriching himself and out of touch with the suffering of ordinary people. Rajoelina, however, comes from the wealthy minority that has had a stranglehold on Madagascar's politics. Political tensions have been rising since late January, when the government blocked an opposition radio station's signal. Rajoelina supporters set fire to a government broadcasting building as well as an oil depot, a shopping mall and a private TV station linked to Ravalomanana. Scores of people were killed. Days later, soldiers opened fire on anti-government protesters, killing at least 25. The incident cost Ravalomanana much of the support of the military, which blamed him for the order to fire. Despite losing support at home, Ravalomanana had been backed by the international community because he was the democratically elected president. U.N. Secretary-General Ban Ki-moon is "gravely concerned about the evolving developments in Madagascar," associate spokeswoman Marie Okabe said at U.N. headquarters in New York. The State Department on Tuesday ordered all nonessential staff at the U.S. Embassy in Madagascar and the families of all American personnel there to leave the country because of the uncertain security situation. According to African Union rules, coups or unconstitutional changes of government are cause for automatic suspension from the bloc. The country is only readmitted when constitutional order is restored, usually by elections. Madagascar is scheduled to host this year's AU summit in June or July, but could not do so if it were suspended. Ravalomanana had warned that his desperately poor country could lose international aid if Rajoelina was allowed to take over.