The contested election in 2013 was taken to the courts, and ended largely peacefully even though Odinga lost.
Nairobi: President Uhuru Kenyatta appeared headed for re-election Wednesday as his rival Raila Odinga rejected early results as "fake", setting nerves on edge in east Africa's richest economy.
With ballots from 90 percent of polling stations counted, electoral commission (IEBC) results showed Kenyatta leading with 54.6 percent of the nearly 13 million ballots tallied against Odinga's 44.5 percent, a difference of 1.3 million votes.
"These results are fake, it is a sham. They cannot be credible," Odinga told a press conference in the early hours of the morning as partial results fell quickly via an electronic tallying system aimed at preventing fraud.
Odinga claimed the IEBC had not provided documents that would show how the tallies were arrived at. "It is the machine that has voted," Odinga told reporters. "These results are wrong."
Odinga, 72, who is making his fourth stab at the presidency as the flagbearer for the National Super Alliance (NASA) coalition, accused his rivals of stealing victory from him through rigging both in 2007 and 2013.
In 2007, the disputed vote resulted in two months of ethnically-driven political violence that killed 1,100 people and displaced 600,000 in a major blow to a nation seen as a regional bastion of stability.
The contested election in 2013 was taken to the courts, and ended largely peacefully even though Odinga lost. The run-up to this year's vote was fraught with tension, heightened by the torture and murder of Chris Msando, a key administrator of the biometric voting system, whose body was found on the outskirts of Nairobi earlier this month. "We fear that this is the precise reason why Mr. Chris Msando was assassinated," Odinga said, referring to his fraud claims.
Winners and losers: Local media praised a calm day of voting Tuesday, but urged the losers to peacefully accept the result and turn to the justice system with their grievances.
"The voters, too, must await the results while acknowledging that their favourite candidate can actually lose. It is a critical measure of democracy that there will be winners and losers," read an editorial in the Daily Nation newspaper.
The normally traffic-choked streets of Nairobi were unusually quiet the day after the vote. However some businesses slowly began opening as the country held its breath over the results.
Odinga asked the IEBC to stop streaming results on its public website until the forms backing up the figures sent in from constituencies could be produced.
However IEBC commissioner Roslyn Akombe declined to do so. "As a commission we decided that as part of the commitment we made to the voters and the Kenyan people, transparency and accountability are part of them."
The will of the people: The contest between Odinga and Kenyatta was seen by pollsters as too close to call ahead of the vote.
It is the second time the two men have faced off in a presidential election in dynastic rivalry that has lasted more than half a century since their fathers Jomo Kenyatta and Jaramogi Odinga went from allies in the struggle for independence to bitter rivals.
The men belong to two of Kenya's main ethnic groups, Kenyatta from the Kikuyu, the largest, and Odinga from the Luo. Both had secured formidable alliances with other influential communities in Kenya, where voting takes place largely along tribal lines.
In 2013 Kenyatta won by 800,000 votes. Kenyatta, 55, is credited with overseeing steady economic growth of more than five percent, however food prices have soared under his watch and several major corruption scandals broke out in his first term.
Raphael Tunju, secretary-general of Kenyatta's Jubilee party, shrugged off Odinga's fraud charge. "I don't expect anything else from NASA," he said. On Tuesday, Kenyatta urged Odinga to accept the result should he lose. "I also want to say that if I lose, I will accept the will of the people," Kenyatta said after voting.
A quiet vote: Despite reports of some technical glitches and delays, Tuesday's vote went off peacefully, and the IEBC moved quickly to deal with any complaints.
A clerk in a polling station where ballot papers were pre-marked as "rejected," was fired, and police arrested another clerk in the port city of Mombasa who was caught issuing double ballot papers to certain voters.
Shortly before polls closed, NASA put out a statement praising poll officials and security forces, but complained that some of its voters had been turned away or not found their names on the register.
NASA also said it had reports of "pre-marked ballot papers" and attempts to bribe voters. Kenyans voted in six different elections, including several knife-edge races for governor that have fired up local tensions.
Early results showed the opposition looked set to lose the governorship of the capital Nairobi which had been seen as a major coup in 2013 to the ruling party candidate.