Nairobi, Kenya (CNN) -- The Kenyan Supreme Court on Saturday upheld Uhuru Kenyatta's victory in the presidential election, dismissing a challenge by his chief rival and ending a drawn-out case that has riveted the nation.
The nation's highest court declared the election "free and fair," ending weeks of uncertainty after the disputed March 4 poll.
Kenyatta, the 51-year-old son of Kenya's founding leader, won the election with 50.07% of the vote.
Raila Odinga, who got 43.31%, had challenged the outcome in court on the grounds that it was flawed and marred by technical problems.
After the court issued its ruling, he said he accepted its judgment and would abide by it.
"The court has now spoken," Odinga said, "I wish the president-elect and his team well."
Odinga said his petition focused on valid failures in the election process.
"My decision to file a petition in the Supreme Court to challenge the validity of the election was a testament of my faith in the independence of our judiciary," he said. "I did so for the sake of our democracy and for the sake of all Kenyans."
Kenyatta will be sworn in April 9, making him the nation's fourth and youngest president.
Kenyatta and Odinga are the sons of the nation's first president and vice president, respectively, bringing back memories of a political dynasty that dates to the 1960s.
Their fathers started out as allies in the quest for Kenyan independence from Britain.
But the elder politicians' relationship ended in bad blood when founding President Jomo Kenyatta forced out his vice president, Jaramogi Odinga, following a series of disputes.
Some five decades later, it is the sons' turn in the spotlight.
'Accept the ruling'
Last week, both leaders pledged to accept the court's decision, assuring citizens that the ruling would end the uncertainty in the nation.
A peaceful response will go a long way toward restoring the nation's image as a bastion of stability in the region after disputed election results led to bloody chaos in 2007.
In that election, more than 1,200 were killed and hundreds of thousands displaced after Odinga disputed the results, which showed incumbent President Mwai Kibaki as the winner.
At the time, supporters of both candidates battled on the streets with crude weapons, not in court.
The outgoing president urged citizens to honor the court ruling and shun violence.
"As the country awaits the Supreme Court ruling, I call upon all of us to accept the ruling and maintain peace," Kibaki said Thursday. "Kenyans should resume their routine economic activities as soon as possible to return normalcy in the country."
The March 4 election was the first general poll since the disputed election. It was conducted under a reformed judicial system and a more inclusive electoral commission.
The significance of Kenya's democratic process extends beyond the country's borders.
Kenya is East Africa's biggest economy and a crucial trade route into the rest of the continent.
It provides an important buffer of stability in a region that includes the fledgling Somali government and the politically tense Sudan and South Sudan.
Kenya is also a major U.S. ally in the war against Islamist militants in the region and has remained relatively peaceful amid civil wars in neighboring nations.
The upholding of Kenyatta's victory raises the prospect of complicated diplomatic ties with the West.
The International Criminal Court has indicted him for allegedly funding a local militia that conducted reprisal attacks in the last election in 2007. His running mate, William Ruto, also faces ICC charges at The Hague, in the Netherlands.
Both have denied the charges and have said they will cooperate with the court to clear their names.
Defiance of the West
Analysts say the ICC indictment may have rallied citizens to Kenyatta's side in defiance of the West.
"Many Africans have lost faith in ICC and view it as targeting African leaders and failing to discharge its justice among non-African leaders," said Ayo Johnson, director of ViewPoint Africa. "Kenya sent a loud message to the ICC ... don't interfere. And it does not matter if you brand our leaders as criminals."
But rights group say the courts are vital to providing justice in cases largely overlooked by governments.
Kenyatta has said the indictment will not affect his ability to do his job, and has urged the international community to respect the will of Kenyans.
The United States and Britain sent accolades to Kenyatta following the ruling. Before elections, officials from both nations had expressed concerns over ICC charges against the president-elect.
British Prime Minister David Cameron wrote to Kenyatta to congratulate him, a Downing Street spokesman said Saturday.
Cameron "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," the spokesman said.
In a statement, the White House also congratulated Kenyatta and urged Kenyans "to peacefully accept the results" of the election.
U.N. Secretary-General Ban Ki-moon also talked to Kenyatta and Odinga and pledged the United Nations' support for the country.
CNN's Nima Elbagir reported from Nairobi. Faith Karimi wrote and reported in Atlanta, while Laura Smith-Spark wrote in London. Zarifmo Aslamshoyeva and Lillian Leposo contributed to this report.