NAIROBI, Kenya — Kenya's Supreme Court on Saturday upheld the election of Uhuru Kenyatta as the country's next president and the loser accepted that verdict, ending an election season that riveted the nation with fears of a repeat of the 2007-08 postelection violence.
Kenyatta supporters flooded the streets of downtown Nairobi, honking horns, blowing plastic noisemakers and chanting.
But supporters of defeated Prime Minister Raila Odinga angrily protested after the verdict and police fired tear gas at them outside the Supreme Court as well as in the lakeside city of Kisumu, Odinga's hometown.
Two young men participating in riots were fatally shot in Kisumu, police said, although it was not clear by whom.
The Supreme Court verdict — following a drawn-out court case that raised tensions across the nation — means that Kenyatta, the son of Kenya's first president, is to be sworn in as president on April 9. He will become the second sitting president in Africa to face charges at the International Criminal Court.
Kenyatta and Deputy President-elect William Ruto face charges that they helped orchestrate the 2007-08 postelection violence in which more than 1,000 people died. Both deny the charges.
Kenyatta's win may complicate the U.S. relationship with Kenya. Because of the charges against Kenyatta, the United States, Britain and other European countries have said they may have limited contact with the new president.
The White House congratulated Kenyatta in a statement, which urged Kenyans "to peacefully accept the results of the election."
Lawyers for Odinga, the loser in Kenya's last two elections, had argued before the Supreme Court that the election was marred by irregularities and that Kenyatta did not win enough votes to avoid a runoff. According to official results, Kenyatta won 50.07 percent of the vote.
The Supreme Court's unanimous decision, read out by Chief Justice Willy Mutunga, said that the election was "conducted in compliance with the constitution and the law" and that Kenyatta and Ruto were legally elected.
In a victory speech late Saturday, Kenyatta urged Kenyans to move past the election and pledged to "work with, and serve, all Kenyans without discrimination whatsoever."
"Above all, let us continue to pray for peace in our country," he said.