Nairobi - From the Indian Ocean coast to Rift Valley towns to Nairobi's slums, Kenyans turned out in large numbers to vote on Tuesday in an election pitting President Uhuru Kenyatta against challenger Raila Odinga in this East African economic hub known for its relative, long-term stability and ethnic allegiances that shadow its democracy.
Many polling stations closed on schedule at 17:00, though some sites remained open to process voters still waiting to cast ballots.
Voters formed long lines at many polling stations before dawn, waiting to cast ballots in the tightly contested race for the presidency as well as for more than 1 800 elected positions, including governors, legislative representatives and county officials.
A key concern is whether Kenya will echo its 2013 election, a mostly peaceful affair despite opposition allegations of vote-tampering, or the 2007 election, which led to violence fueled by ethnic divisions that killed more than 1 000 people.
"If the elections are not fair, if there was rigging, people will definitely go to the streets," said Sophia Ajwang, a 29-year-old student in Kisumu city.
However, Moses Otieno, a 33-year-old businessman, said that Kenyans desperately want to avoid another bout of election unrest.
"We've learned a lot in the past, so we don't want such repetition in this election," Otieno said. "That's why we will accept whatever outcome it is."
Three polling stations in the Laikipia area were "affected by insecurity," but security forces restored order and polling resumed, Kenya's election commission said.
Farms and homes in Laikipia County have been under siege for more than a year from herders who say they are desperate for grazing land for their animals; some farmers believe the land invasions are politically motivated.
Kenyatta, the 55-year-old son of Kenya's first president after independence from British colonial rule, campaigned on a record of major infrastructure projects, many backed by China, and claimed strong economic growth.
Odinga, 72, also the son of a leader of the independence struggle, has cast himself as a champion of the poor and a harsh critic of endemic corruption.
However, many voters are expected to vote along ethnic lines. Kenyatta is widely seen as the candidate of the Kikuyu people, the country's largest ethnic group. Odinga is associated with the Luo voting bloc, which has never produced a head of state. There are six other presidential candidates, though they lack the wide support of the top two.
"I feel positive because we ran a positive campaign," Kenyatta, who seeks a second term, said after voting in his birthplace of Gatundu, north of Nairobi.
Odinga voted in the poor area of Kibera, an opposition stronghold in the capital, Nairobi.
"Uhuru must go," chanted his supporters, referring to the president by his first name.
More than 300 people, including ethnic Maasai draped in traditional red blankets, waited for hours in the dark before a polling station opened in the Rift Valley town of Il Bissil.
Kenyan television also showed long lines of voters in the port city of Mombasa. In some locations, inmates in striped prison garb cast ballots under the watch of guards.
"There are a lot of people in line, and it is going to take some time, and we are going to need to be very patient," said former US Secretary of State John Kerry, who is in Kenya as chief election observer for The Carter Center. "But obviously, the transition from voting to counting is going to be critical and there is a process in place for that too."
Reaction to the result could partly depend on the performance of Kenya's electoral commission, which will collect vote counts from more than 40 000 polling stations. Fears of violence were increased by the murder of an electoral official in charge of technology days ahead of the election.
The election commission has said about 25% of polling stations won't have network coverage, meaning officials will have to move to find a better signal and transmit results by satellite telephones. By law, election officials have up to a week to announce results, though many analysts believe the outcome of the presidential race will be declared far sooner, possibly within one or two days.
The winner of the presidential race must get more than 50% of the votes as well as one-quarter or more votes in at least 24 of Kenya's 47 counties, according to officials. If the front-runner falls short of those benchmarks, the two top contenders will contest a run-off vote.
President Kenyatta and challenger Odinga also faced off in the 2013 election. Kenyatta won by a thin margin, with just over 50% of the vote; Odinga alleged voting irregularities and took his case to Kenya's highest court, which ruled in Kenyatta's favor by validating the results.
Kenya has nearly 20 million registered voters out of a population of more than 40 million.