President Uhuru Kenyatta has been declared the winner of Kenya's hard-fought presidential election but opposition candidate Raila Odinga alleged the voting was rigged.
In announcing the results of Tuesday's contest, the election commission said Kenyatta won a second term with 54 percent in balloting it called "credible, fair and peaceful."
Hundreds of riot police were in the streets of the capital, Nairobi, amid fears of further protests by opposition supporters who called the vote a "charade" and said challenging the outcome in court wasn't an option.
Mr Kenyatta, the 55-year-old son of Kenya's first president after independence from Britain, appealed for calm and unity after the bitter campaign.
"Kenya belongs to all of us," he said. "Let us shun violence and let us refuse to be used for short-term political gain."
He said he was extending a "hand of friendship" to "our older brother," Mr Odinga.
"We need and must continue to work together for the welfare of our people and in order to keep this country united," said Kenyatta, who also defeated Odinga in 2013.
"We reach out to you. We reach out to your supporters."
The election was a test of stability for the East African economic power as many recalled the post-election bloodshed a decade ago that left more than 1,000 dead.
Kenyatta added: "We have seen the results of political violence and I am certain there is no single Kenyan who would wish to go back to those days."
Kenya had been relatively calm since the election but had braced for possible violence Friday night with police in the central business district.
Gunshots and screams were heard in at least two areas of Kenya populated by Odinga supporters, according to police and a witness.
The shooting was heard in the Nairobi slum of Kibera and in the southwestern city of Kisumu, the witnesses said. Youths were also reported to be throwing stones at cars.
"There are gunshots all over; we don't know how it will end but we are praying for peace," said Kisumu resident Lucas Odhiambo, adding that people were bellowing through "vuvuzela" noisemakers when the results were announced "and police moved in".
Earlier in the day, opposition supporters burned tires and blocked roads in several areas.
The election commission rejected claims by Odinga, a former prime minister, that its database was hacked and results manipulated against him.
The long wait for election results increased tensions in the nation of 45 million people, though the commission by law had until Aug. 15 to announce them.
At least three people were killed in clashes between police and opposition supporters this week.
Odinga alleged hackers infiltrated the election commission's computer system in favor of his opponent.
He claimed the hackers used the identity of Christopher Msando, an election official in charge of managing information technology systems.
Officials had announced on July 31 that Msando had been tortured and killed.
In addition, the American CEO of an election data company working for Odinga was deported last weekend.
The election commission said there was a hacking attempt but it failed, and Odinga's camp had no right to declare him as the winner.
Earlier Friday, the opposition said it had asked for access to the commission's servers to confirm whether the alleged hacking took place.
If granted, it said it would accept the results, even if they showed that Kenyatta won.
Kenyatta has not commented on Odinga's allegations.