“We want change!” yelled Abdi Mubarak, who works in a mosque and who said he voted for Mr. Odinga.

That change may come. Though official results are not expected to be released until Friday, most polls in the past several months forecast that Mr. Odinga would win the popular vote, and the heavy turnout on Thursday was said to work in his favor. It seems that he has tapped into frustrations percolating for some time in Kenya, which enjoys one of the strongest and most stable economies in Africa but suffers from deep tribal divisions. Mr. Odinga has built a coalition of the Luo, the Luhya, the Masai, the Somali and many other tribes who say they feel that the Kikuyu, Kenya’s biggest tribe, accounting for a quarter of the population, has been politically dominant for too long.

Image A team of workers with the Kenyan Election Commission counted ballots on Thursday at a church in Nairobi, the capital. Credit... Evelyn Hockstein for The New York Times

On Thursday, this played out behind the cardboard booths where voters hunched over their ballots. Of more than a dozen people interviewed, not one crossed tribal lines when voting. Mr. Odinga, 62, is a Luo. Mr. Kibaki, 76, is a Kikuyu. And the third notable politician in the presidential race, Kalonzo Musyoka, 54, is a Kamba.

“I’m for the president,” said David Ndagwa, a stocky vendor of vegetables who said he was a Kikuyu. “He’s brought progress.”

Tribes aside, there are other issues in this race. Mr. Odinga wants to devolve power from the center of the country and grant Kenya’s rural areas more autonomy. Mr. Kibaki has been running strong on education and has already delivered on his promise of free primary school education for all Kenyans. Mr. Musyoka is a former foreign minister and has said he is the one to expand Kenya’s links to the wider world. He has run a distant third in polls.

However, Kenyan law necessitates that to become president, a candidate must win a seat in Parliament and secure at least 25 percent of the votes in five out of eight of the country’s provinces. This electoral fine print may mean that even if there is a clear winner in the popular vote, there could be a runoff.