Uhuru Kenyatta was declared winner of Kenya's presidential election Saturday with just enough of a margin to avoid a runoff after a race that has divided the nation along tribal lines.

Kenyatta, the son of Kenya's founding president, faces trial for crimes against humanity after the disputed 2007 presidential vote that unleashed a wave of ethnic bloodletting.

The United States and other big donors to the East African nation said before the vote that a Kenyatta win would complicate ties with a nation viewed as a vital ally in the regional battle against militant Islam.

The final results showed that Kenyatta won 6,173,433 votes — 50.07 percent — to Prime Minister Raila Odinga's 5,340,546 — 43.3 percent, the Associated Press reported. More than 12, 330,000 votes were cast, a record turnout of 86 percent registered voters.

The chairman of the Independent Electoral and Boundaries Commission, Issack Hassan, announced:

"I therefore declare Uhuru Kenyatta the duly elected president of the Republic of Kenya," he said, according to Reuters. Then he handed a certificate of the results to Kenyatta, who thanked him.

Many in the election center cheered, although celebrations started in the early hours of Saturday after provisional results showed Kenyatta's victory. Supporters thronged the streets of Nairobi and strongholds of his Kikuyu people, lighting fluorescent flares and waving tree branches and chanting "Uhuru, Uhuru," which means freedom.

Less than two hours after the announcement, Odinga said the election process experienced multiple failures and that he would petition the Supreme Court, the AP reported.

Odinga called for calm and asked Kenyans to love one another but said he would not concede because he did not believe he had lost.

"I have stated that nothing could have pleased me more if I had lost fairly," he said, adding: "We have highlighted so many irregularities with the tallying process."

Kenyatta was immediately afforded the state security that would accompany a president-elect, traveling in a shiny black convoy from the tallying center to his election center. In his victory speech, he thanked Odinga — "my brother" — for a spirited campaign and promised to be the president for all Kenyans.

The election commission, plagued by technical problems that slowed the count, took five days to announce the result.

Both sides relied heavily on their ethnic groups in a nation where tribal loyalties mostly trump ideology at the ballot box. Kenyatta is a Kikuyu, the biggest of Kenya's many tribes, Odinga is a Luo. Both had running mates from other tribes.

How Western capitals deal with Kenya under Kenyatta and the extent they would be ready to work with his government will depend heavily on whether Kenyatta and his running mate William Ruto, who is also indicted, cooperate with the tribunal.

"It won't be a headache as long as he cooperates with the ICC," one Western diplomat told Reuters. "We respect the decision of the majority of the Kenyan voters."

Both Kenyatta and Ruto deny the charges and have said they will work to clear their names.

Kenyatta has said the indictment will not affect his ability to do his job, CNN reported.

"I have been a member of the government and I've still been able to execute my duties," said Kenyatta, a deputy prime minister in the outgoing administration. "I still believe I will be able to execute my duties as president once selected."

Kenyatta will be the second African president to be charged before the International Criminal Court -- the first was Sudan’s Omar Hassan al-Bashir. Kenyatta has been charged with bankrolling death squads that targeted women and children as well as other crimes against humanity in connection with the post-2007 election violence.

Since then, Kenya has taken steps to reassure the public of a fair, free, and transparent election using the Independent Electoral and Boundaries commission, the country's own electoral watchdog group.

This year's election saw much less bloodshed in comparison to several years ago. Nonetheless, at least 15 people were reported killed in two separate attacks, one in the major coastal port city of Mombasa, and one in the small town of Kilifi, about 80 miles to the north, several news accounts said.

Jendayi Frazer, former U.S. assistant secretary of state for African affairs and a fellow with the Council on Foreign Relations, said she does not foresee much change in ties between Kenya and the United States.

"Kenyatta knows that he needs the United States and the United States knows it needs Kenya.," she told CNN. "And so I suspect that while it might be awkward, there won't be a significant change in our policy stances toward Kenya or theirs toward us."

The ICC indictment may in fact have rallied voters to Kenyatta's side to defy 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 in the world," said Ayo Johnson, director of ViewPoint Africa.