Kenya’s Supreme Court has upheld Uhuru Kenyatta’s presidential election victory, rejecting several petitions challenging the vote.
Chief Justice Willy Mutunga announced the decision, which was unanimous, saying the poll was free and fair.
Main challenger PM Raila Odinga, who lodged the appeal, said he would fully respect the verdict.
Official results said Mr Kenyatta beat Mr Odinga by 50.07% to 43.28%, avoiding a run-off by just 8,100 votes.
There was tight security at the Supreme Court as the judgement was read out. Violence after a disputed election in 2007 left more than 1,200 people dead.
The presidential, legislative and municipal elections held on 4 March were the first since the 2007 poll.
Mr Kenyatta and his running mate, William Ruto, are expected to be sworn in as president and vice-president on 9 April
But they are facing trial on charges of crimes against humanity at the International Criminal Court (ICC) for allegedly fuelling unrest after that election. They deny the charges.
Plea for calm
Chief Justice Mutunga said the court’s decisions had been unanimous on all the issues they were asked to rule on.
He said that Mr Kenyatta and Mr Ruto had been “validly elected” in a poll carried out in a “free, fair, transparent and credible” manner.
“It is the decision of the court that the said elections were indeed conducted in compliance with the constitution and the law,” he said.
“At this historical moment in our country, the Supreme Court has discharged its constitutional duty in conformity with the solemn oath each one of us took,” he added.
“It is now for the Kenyan people, their leaders, civil society, the private sector and the media to discharge theirs, to ensure that the unity, peace, sovereignty and prosperity of the nation is preserved. God bless Kenya.”
Supporters of Mr Kenyatta took to the streets of central Nairobi, tooting their horns, blowing on vuvuzelas and chanting.
Outside the courthouse, police used tear gas to chase away people protesting against the ruling but the area is now quiet.
There were also reports of tear gas being fired at stone-throwing youths in the western city of Kisumu, a stronghold of Mr Odinga.
And there was an angry mood in the Nairobi slum of Kibera, our correspondent says, with people chanting “no Raila no peace”.
Outgoing President Mwai Kibaki has urged people to stay calm and accept the result, but much will depend on Kenyans’ faith in their newly reformed judiciary, our correspondent says.
Petitions had been filed to the court by Mr Odinga and by civil society groups, who claimed irregularities had affected the election result and called for fresh elections.
Mr Odinga expressed “dismay” at the conduct of the election and said that he did not regret making the challenge.
But he said that he fully respected the decision and wished Mr Kenyatta and his team well.
“Although we may not agree with some of [the court’s] findings, our belief in constitutionalism remains supreme,” he said at a news conference after the verdict.
“We must soldier on in our resolve to reform our politics and our institutions.”
‘Triumph of democracy’
UK Prime Minister David Cameron congratulated Mr Kenyatta on his election victory.
“The prime minister urged the Kenyan people to be proud of the strong signal they have sent to the world about their determination to exercise their democratic right peacefully,” Mr Cameron’s office said in a statement.
A European Union statement said: “Kenyans can be proud that the political reform process of their country is bearing fruit.
“With continued efforts to implement the new constitution, Kenyans can build the globally competitive and prosperous nation they aspire to be.”
Mr Kenyatta has called the election, which was largely conducted peacefully, a “triumph of democracy”.
The Independent Electoral and Boundaries Commission (IEBC) has insisted that the vote was credible, despite technical failures with an electronic voter ID system and the vote counting mechanism.
International observers said the poll was largely free, fair and credible, and that the electoral commission had conducted its business in an open and transparent manner.