NAIROBI, Kenya (AP) — Polls closed across Kenya after millions voted peacefully Tuesday in a fiercely contested election pitting President Uhuru Kenyatta against challenger Raila Odinga in the East African country known for its stability but also its divided ethnic allegiances.
Long lines formed at many of Kenya's 40,000 polling stations before dawn, but the Kenyan election commission tweeted in the evening that the balloting concluded "with minimal hitches." Some sites remained open to process those people still waiting to cast their votes.
In preliminary results, Kenyatta was ahead with 55.4 percent while Odinga had 43.9 percent after votes from nearly one-quarter of 40,883 polling stations had been counted, according to the Kenyan election commission.
Authorities hope to avoid the post-election violence a decade ago when ethnic divisions fueled unrest that killed more than 1,000 people. A 2013 vote was mostly peaceful despite opposition allegations of vote-tampering.
Reaction to the result could partly depend on the performance of Kenya's electoral commission, which will collect and count the ballots in the coming days. In addition to the bitterly contested presidential race, more than 1,800 elected positions were at stake, including governors, legislative representatives and county officials.
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.
Former U.S. Secretary of State John Kerry, who is the chief election observer for The Carter Center, described it as "an inspiring day in Kenya watching democracy in action."
"Enthusiastic voters not fazed by long lines," he tweeted.
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 TV also showed lines of voters in the port city of Mombasa. In some locations, inmates in striped prison garb cast ballots under the watch of guards.
Because Kenya is an African leader, its election is a closely watched event across the continent and beyond. Its diversity, symbolized by the gulf between its so-called Silicon Savannah ambitions for a booming tech industry and the poverty and lack of services found in shantytowns or remote rural areas, as well as its complex ethnic patchwork, mirror the potential for advancement, and the obstacles to it, across the wider region.
"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, the 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 were 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.
The winner of the presidential race must get more than 50 percent 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.
Kenyatta and Odinga also faced off in the 2013 election. Kenyatta won by a thin margin, with just over 50 percent 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.
Associated Press journalists Tom Odula in Nairobi and Jerome Delay in Il Bissil contributed.