Kenyans are braced for a potentially turbulent time ahead after the disputed outcome of the country's presidential election triggered violent protests in some areas.

After an anxious days-long wait for the results of the 9 August poll, Deputy President William Ruto was declared the winner, beating his rival Raila Odinga by a narrow margin after a largely peaceful voting process.

But the announcement did little to calm nerves, with the election commission itself split over the outcome and demonstrators in Mr Odinga's strongholds hurling stones and setting fire to tyres.

With the trauma of previous post-election violence still looming over Kenya, both Mr Odinga and Mr Ruto had previously pledged to deal with any disputes in court rather than on the streets.

But that did not stop supporters of 77-year-old Mr Odinga from packing the streets in his stomping ground in the lakeside city of Kisumu, where they clashed with police who fired tear gas to disperse them.

Protests also erupted yesterday in two Nairobi slums which have long been bastions of support for Mr Odinga.

No presidential poll outcome has gone uncontested in Kenya since 2002, and a Supreme Court challenge by Mr Odinga is seen as almost certain, with his running mate Martha Karua saying on Twitter: "It is not over till it is over."

The race remained tight until the end, with Mr Ruto scoring 50.49% of the vote compared to 48.85% for Mr Odinga, according to Independent Electoral and Boundaries Commission (IEBC) chairman Wafula Chebukati.

Police fire tear gas as people protest after election results were announced in Kenya

As Kenyans wait to hear from Mr Odinga after losing his fifth bid for the presidency, four of the seven IEBC commissioners have already rejected the outcome, with one describing the process as "opaque".

The dispute is likely to further damage the reputation of the IEBC after it had faced stinging criticism over its handling of Kenya's annulled 2017 election.

But Mr Chebukati, who was also in charge of the IEBC in 2017, insisted he had carried out his duties according to the law of the land despite facing "intimidation and harassment".

All eyes on Odinga

Although Mr Ruto, 55, has promised to work with "all leaders", saying, "there is no room for vengeance", all eyes will be on Mr Odinga in the days ahead, with analysts warning that demonstrations will likely continue in Kisumu and pockets of Nairobi.

"The tightness of the final tally has inevitably increased the probability of disruptions," the Eurasia Group consultancy said in a note, adding, however, that "widespread unrest remains unlikely".

The country of about 50 million people is already struggling with soaring prices, a crippling drought, endemic corruption and growing disenchantment with the political elite.

While several African leaders congratulated Mr Ruto, the US embassy instead issued plaudits to Kenya's voters and the IEBC, while urging political rivals to settle their differences over the election peacefully.

Mr Ruto, a rags-to-riches businessman, had painted the vote as a battle between ordinary "hustlers" and the "dynasties" who have dominated Kenyan politics since independence from Britain in 1963.

Supporters of William Ruto celebrate following the election result

Any challenge to results must be made within seven days to the Supreme Court, which then has 14 days to issue a ruling. If it orders an annulment, a new vote must be held within 60 days.

If there is no court petition, Mr Ruto will take the oath of office in two weeks' time, becoming Kenya's fifth president since independence.

In August 2017, the Supreme Court annulled the election after Odinga rejected the results. Dozens of people were killed by police in the protests that followed.

The worst electoral violence in Kenya's history occurred after a disputed vote in 2007, when more than 1,100 people were killed in bloodletting between rival tribes.