(Adds details, background)
NAIROBI, March 9 (Reuters) - Uhuru Kenyatta, the son of Kenya's founding president, won the presidential election with a slim margin of 50.03 percent of votes cast, just enough to avoid a run-off, provisional figures by the election commission showed on Saturday.
Kenyatta, who faces international charges of crimes against humanity, secured the victory over his main rival, Prime Minister Raila Odinga, who secured 43.28 percent of the vote.
The first round win, which must be officially confirmed by the Independent Electoral and Boundaries Commission, means Kenyans who waited five days for the result of the vote will not face a run-off that would have prolonged the uncertainty.
To secure an outright win, a candidate needed more than 50 percent of the votes.
Kenyatta achieved that by a margin of just 4,100 votes. About 12.3 million votes were cast. Such a narrow win will almost certainly prompt legal challenges from Odinga's camp, which complained about the election process throughout.
Kenyatta, the deputy prime minister, secured 6,173,433 votes out of a total of 12,338,667 ballots cast, the provisional figures showed, indicating a margin of 50.03 percent.
Western donors had warned before the vote that diplomatic ties would be complicated with a win by Kenyatta who, along with his running mate William Ruto, is facing charges of crimes against humanity at the International Criminal Court in The Hague related to post-election violence five years ago.
Kenyans hoped this vote would restore their nation's reputation as one of Africa's most stable democracies after the tribal slaughter that followed the disputed 2007 vote that Odinga said Mwai Kibaki stole from him.
The test will be whether any challenges to the outcome are worked out in the courts of the newly reformed judiciary, and do not spill over into the streets, as they did in 2007. (Reporting by George Obulutsa; Writing by Edmund Blair; Editing by James Macharia and Stacey Joyce)