The declaration, which was made on Friday, was despite alleged rigging allegations during the December run-off vote, in which Rajaonarimampianina defeated his rival.
The ruling raises the spectre of protests by supporters of Jean Louis Robinson who had demanded a recount and warned on Thursday that his patience was wearing thin.
Any prolonged row over the result of the Dec. 20 vote, the first since a coup on the Indian Ocean island in 2009, threatens to extend a political crisis that has sharply slowed economic growth and deepened poverty.
An aide to Robinson, who was backed by Marc Ravalomanana, the man ousted from power five years ago, this week said he would outline the “irregularities” to the Southern African Development Community and African Union. Both blocs had worked on a political deal to push Madagascar towards an election.
The electoral court said Rajaonarimampianina won 53.5 percent of the vote to Robinson’s 46.5 percent, confirming the electoral commission’s provisional results.
There was no immediate reaction from Robinson, who a day earlier said: “We are ready to defend the choice of the people until the end.”
Robinson’s ally, Roland Ravatomanga, a minister in the power-sharing government, said: “We will only stop when Jean Louis Robinson is installed as president.”
The vote was meant to end a crisis that has driven out investors, cut aid flows and led to Madagascar’s diplomatic isolation.
“I urge goodwill from everyone so that we can build a prosperous and stable nation,” said Rajaonarimampianina, who was backed by the outgoing president, Andry Rajoelina, who spearheaded the 2009 coup.
A drawn-out dispute is likely to stir up further the nickel-producing island’s volatile political scene and could delay restoring the external budget support needed to spur public spending and kick-start growth.
“Everyone should accept the court’s result,” said mechanic Faly Ranarison shortly before Friday’s ruling.
“Let the country be peaceful and wait for the next election to set the record straight.”
The streets of the capital Antananarivo, where Rajaonarimampianina had struggled to win support in the first round, were calm after the court’s announcement, though some fretted about the risk of unrest.
“I’m worried,” said teacher Noro Ravaonirina. “Recently there’s been a talk, for right or wrong, about vote rigging. In such an environment you can’t exclude that the loser won’t accept his defeat easily.”