Kenya's Supreme Court on Saturday upheld Uhuru Kenyatta's presidential election victory, throwing out a bid by his rival for a new poll amid fears of violence.
The court unanimously ruled that the March 4 election had been fair and credible and that Kenyatta and his running mate had been "validly elected".
Kenyatta's main rival Raila Odinga accepted the ruling, but supporters protested in his stronghold in western Kenya.
"The presidential election ... was conducted in a free, fair, transparent and credible manner in compliance with the provisions of the constitution and all relevant provisions of the law," Chief Justice Willy Mutunga said.
"It is the decision of the court that the 3rd and 4th respondents (Kenyatta and his deputy William Ruto) were validly elected," Mutunga said.
The ruling paves the way for Kenyatta, the son of Kenya's first president and one of Africa's richest men, to be sworn in as head of state on April 9.
The six judges dismissed petitions filed by Odinga, outgoing prime minister and Kenyatta's main rival in the presidential race, and by civil society groups, over what they claimed was a series of irregularities that skewed the election results.
The petitioners had called for fresh elections to be ordered.
Odinga said he accepted the court's ruling and wished his rival well. Protests broke out in two towns in his stronghold of western Kenya -- Homa Bay and Kisumu.
"The court has now spoken," Odinga said, adding that while he might not agree with all its decisions his faith in the constitution "remains supreme".
At least two people sustained gunshot wounds in Kisumu as police battled protestors who blocked a road, lit bonfires and pelted them with stones, an AFP correspondent said.
"We did not expect such a ruling at all, it is so unfair for us," John Ochieng, a mechanic among the protestors, said.
Two-and-a-half hours after the court ruling protestors had been dispersed in both towns, residents said.
Incidents were also reported in two Nairobi slums but the extent of the trouble was difficult to ascertain. Residents reported that protestors were calming down after a couple of hours.
"We have tensions in areas in Mathare and Huruma but we have sent in more police officers to calm them down," Nairobi police chief Benson Kibui said.
"There are groups clashing over the court decision but everything will be OK. We have enough officers on the ground," he said.
Kenya's last elections in 2007 were marred by violence on a much larger scale, with more than 1,100 people killed and several hundred thousand forced to flee their homes.
Kenyatta and Ruto both face trial at the International Criminal Court in The Hague for crimes against humanity over their alleged role in planning the 2007-2008 post-election violence.
Mutunga said the judges would make the reasons for their decision public within two weeks.
Official results showed president-elect Kenyatta won 50.07 percent of the votes -- just making it over the 50-percent threshold needed to avoid a second-round ballot by some 8,000 votes. He was declared the winner on March 9.
"It is important the process has come to an end," Kethi Kilonzo, counsel for one of the civil society groups that filed a petition, said in a TV interview.
The European Commission, Britain and France all congratulated Kenyatta on his victory.
Television footage from Gatundu, the town where Kenyatta was born and raised, showed motorbike riders sounding their horns in triumph as they drove down the main street.
Tensions had been running high ahead of the ruling. Police were out in force around the building housing the court in central Nairobi, with Kenya's police chief David Kimaiyo warning gatherings around the court would not be tolerated.
Just after the announcement of the decision a group of some 200 supporters of Odinga was swiftly dispersed by police who used tear gas.