With a poster of presidential candidate Raila Odinga behind him, a supporter of the Coalition for Reforms and Democracy (CORD) sits outside his house and listens to the results of Kenya's election on his radio in Nairobi, on March 7, 2013. (Sayyid Azim/AP)

Deputy Prime Minister Uhuru Kenyatta, who faces charges of committing crimes against humanity, won Kenya’s presidential election by the narrowest of margins, winning 50.03 percent of the vote and avoiding a runoff, according to preliminary results posted early Saturday.

The tight finish is almost certain to spark controversy and will probably result in a legal challenge from Kenyatta’s main rival, Prime Minister Raila Odinga, whose party has already publicly charged that votes were doctored. Kenyatta reached the 50 percent needed to avoid a runoff by only 4,099 votes out of more than 12.3 million cast. Odinga secured 43.28 percent of the vote in an election contested by eight candidates.

The tally still needs to be confirmed by Kenya’s Independent Electoral and Boundaries Commission, which said that it would officially announce the results of the election at 11 a.m. Saturday in the capital, Nairobi.

On Saturday morning, ahead of the announcement, news agencies were quoting Odinga advisers saying that he would not concede the election and that if Kenyatta was officially announced as Kenya’s next President and that a court challenge would be launched.

“We are going to court,” said Millie Odhiambo, a parliamentarian with Odinga’s party. “You concede only when there is a credible process. But this was not a credible process.”

In downtown Nairobi as well as in Kenyatta’s strongholds across the country, local television carried images of people celebrating in the streets, dancing and chanting Kenyatta’s name. There were no reports of violence.

For most Kenyans, the concern is whether any potential challenges will be undertaken in Kenya’s courts or on the streets. In the previous presidential election in 2007, Odinga declared that he was cheated out of victory, triggering ethnic violence that killed more than 1,000 Kenyans and drove several hundred thousand more from their homes. The mayhem crippled Kenya’s economy and shattered its image as a bulwark of stability in Africa.

If Kenyatta’s victory is upheld, it would also complicate Kenya’s relationships with the United States and European nations, which have already warned that there could be consequences if Kenya is led by someone indicted by the International Criminal Court at The Hague. Both Kenyatta and his running mate, William Ruto, are accused of financing and instigating ethnic mobs who carried out killings after the 2007 election. Their trial, originally scheduled for next month, has been postponed to July 9. Both men have denied the allegations and have said they would cooperate with the court in order to clear their names.

At the same time, the United States and its allies rely on Kenya as a key counterterrorism ally. Kenya has played an important role in the fight against Somalia’s al-Qaeda-linked al-Shabab militia. Kenya’s economic stability is also vital to the region’s and the continent’s growth.

International elections observers have declared the election transparent despite a host of technical problems and delays. The computers generating the electronic transmission of results broke down, forcing the electoral commission to manually count the votes.

The election was thrown into more disarray Thursday after Odinga’s party alleged that preliminary results were fraudulent and called for the vote count to be halted.

“We have evidence that results we have been receiving have actually been doctored,” Kalonzo Musyoka, Odinga’s running mate, told reporters in the capital. “The national vote-tallying process lacks integrity and has to be stopped.”

Musyoka added Thursday that his comments were not a call for Odinga’s supporters to wage mass action, and he urged them to remain calm. In Nairobi and other parts of the nation, the streets were quiet after Musyoka’s remarks. In interviews, many Kenyans said they would accept the results or challenge them through the courts rather than plunge their country into mayhem.