At least 15 people were killed in attacks by machete-wielding gangs on Monday as millions of Kenyans voted in the first presidential election since a disputed 2007 poll unleashed weeks of tribal bloodshed.
Voting the tight contest passed off peacefully across most of the East African nation, although many of its 14.3 million voters were caught in long lines. Election officials said there was a high turnout without giving figures.
Officials and candidates have made impassioned appeals to avoid a repeat of the tribal rampages that erupted five years ago when disputes over the poll result fuelled clashes between tribal loyalists of rival candidates.
More than 1,200 people were killed, shattering Kenya's reputation as one of Africa's most stable democracies and bringing its economy, sub-Saharan Africa's fourth-largest, to a standstill.
Just hours before voting began, at least nine security officers in the restive coastal region were hacked to death in two attacks, and six attackers were killed, regional police chief Aggrey Adoli said.
Senior police officers blamed the attacks on a separatist movement, suggesting different motives to those that caused the post-2007 vote ethnic killings that could limit their impact.
As in 2007, the race has come down to a high-stakes duel between two candidates, this time between Deputy Prime Minister Uhuru Kenyatta and Prime Minister Raila Odinga, the loser in 2007 to outgoing President Mwai Kibaki. Both contenders will depend heavily on votes from their tribes.
The United States and Western donors are worried about the stability of a nation that is an ally in the fight against militant Islam in the region.
They are also concerned about how to respond to a victory by Kenyatta, who faces charges by the International Criminal Court of orchestrating violence five years ago.
"If elected, we will be able to discharge our duties," said Kenyatta's running mate, William Ruto who also faces charges of crimes against humanity. "We shall cooperate with the court with a final intention of clearing our names."
Initial provisional results for the presidential race began trickling in moments after polls closed at 5 pm (2 pm GMT), but it was too early to predict an outcome.
Many polling stations will close later because their opening was delayed and some still had long lines. The election commission has seven days to announce the official outcome. Polls suggest there could be a run-off, provisionally set for April.
The European Union observer mission said turnout was high even at the coast where the attacks took place.
"The atmosphere observed is mostly calm," Alojz Peterle, chief of EU Observer Mission and former Slovenian prime minister, told reporters at a polling station in central Nairobi.
"People still queue peacefully and patiently. We hope that this peaceful and patience atmosphere will last until the end of the procedure even if it takes longer than expected."
One of the attacks on Monday took place on the outskirts of Mombasa and another in Kilifi about 50 km (80 miles) to the north. Senior police officers blamed them on a separatist movement, the Mombasa Republican Council (MRC), which wanted the national vote scrapped and a referendum on secession instead.
At the Kilifi site, Reuters footage showed a piece of paper on the ground with the words: "MRC Coast is not Kenya. We don't want elections. We want our own country."
But the group's spokesman denied responsibility and said it only sought change by peaceful means.
Even before the violence, many Kenyans were wary, notably in hotspots last time. Some shopkeepers ran down stocks and some people in mixed tribal areas returned to their homelands. But broadly the vote passed off smoothly with most complaints related to the long wait or delayed opening of polling stations.
"Kenya is greater than any of us. Let the will of the people prevail to avert violence," said accountant George Omondi, 33, in Kisumu, a flashpoint city last time when violence flared after the 2007 result. "We have learnt from the past and should any of the contenders lose, they should accept the outcome."
Kenya's neighbors have been watching nervously, after their economies felt the shockwaves when violence five years ago shut down trade routes running through east Africa's biggest economy. Some landlocked states have stockpiled fuel and other materials.
Adding to tension, the al-Shabaab Islamist militant group battling Kenyan peacekeeping troops in Somalia, urged Muslims to boycott the vote in Kenya and wage jihad against its military.
In Garissa, a largely Muslim town with a significant ethnic Somali population, two civilians were shot dead late on Sunday. A bomb blast in the Mandera area near the border wounded four. Officials did not say who were behind the incidents.
Voters were undeterred. In the early hours before voting, some Kenyans blew whistles and trumpet-like "vuvuzelas" to wake up voters, and queues formed hours before polls opened at 6 am.
"Our future is uncertain, but we long for peace and victory is on our side this time round," said Odinga supporter 32-year-old Eunice Auma in Kisumu, where violence flared after 2007.
"However, should our candidate [Odinga] fail to clinch victory. I'm afraid violence will erupt," she said.
Kibaki, barred from seeking a third five-year term, made what he described as a "passionate plea" for a peaceful vote. All the candidates have vowed to accept the result.
Although the two leaders are well ahead of the other six contenders, polls suggest they will struggle to secure an outright win, which could make for a tense run-off. A narrow first-round victory for either could spark legal challenges.
To try to prevent a repeat of the contested outcome that sparked the violence after the December 2007 vote, a new, broadly respected election commission is using more technology to prevent fraud, speed up counting and increase transparency.
To build confidence, Kenya has passed a new constitution since 2007, police chiefs have deployed extra forces to maintain security and there is a more independent judiciary which commands greater respect. Officials have appealed to candidates to raise any challenges in the courts and not on the streets.
Even so, Odinga, 68, has lifted a warning flag, telling Reuters two days before the vote that the commission had by "design or omission" failed to register all voters in his strongholds, a charge the commission denies.
Alongside the presidential race, there are hotly contested elections for senators, county governors, members of parliament, women representatives in county assemblies and civic leaders.