Kenya's president took an early lead as results from the country’s national elections trickled in, the culmination of a hard-fought contest between the East African nation's foremost political dynasties.

Shrouded in fears of violence, the vote pitted President Uhuru Kenyatta, a wealthy 55-year-old businessman and the son of Kenya's founding president, against Raila Odinga, 72, a former political prisoner and son of Kenya's first vice-president.

Mr Kenyatta had nearly 58% of the vote after 5,455 of 40,883 polling stations had reported results, the electoral commission website said at 6pm Irish time.

Opinion polls released a week ago put both candidates neck-and-neck.

Campaigning was marked by fiery rhetoric but public speeches were largely free of the ethnic hatred that has married previous contests as the two men faced off for a second time.

The electoral commission urged voters to wait calmly for results.

"During this critical phase, we urge all Kenyans to exercise restraint as we await official results from the polling stations and indeed as they start trickling in," it said.

Mr Odinga comes from the Luo people in western Kenya, an area that has long felt neglected by the government and resentful of their perceived exclusion from political power.

Mr Kenyatta is a Kikuyu, an ethnic group that has supplied three of Kenya's four presidents since independence from Britain in 1963.

Any glitches - innocent or otherwise - in the high-tech electronic voting and tallying system could be grounds for the loser to allege fraud, as Mr Odinga did in 2007 and in 2013.

A decade ago, vote tallying was abruptly stopped and the incumbent president declared the winner, triggering an outcry from Mr Odinga's camp. The ethnic violence that followed killed1,200 people and displaced 600,000.

This time, the government deployed more than 150,000 security personnel, including wildlife rangers, to protect 41,000 polling stations.

Thousands of people had returned to their ethnic heartlands before the vote, fearful of a repeat of 2007's violence.

Voting was mostly smooth and turnout was high, the election commission said, despite some isolated incidents and delays. The police said there were no major problems.

In addition to a new president, Kenyans are electing lawmakers and local representatives, the result of a 2010 constitution that devolved power and money to the counties, reducing the "winner takes all" nature of the presidential race.

As he voted, Mr Kenyatta said he would be willing to step down if he lost and called on Mr Odinga to do the same.

"In the event that they lose, let us accept the will of the people. I am willing myself to accept the will of the people, so let them too," he said as he.

Hundreds of people had waited in line since 2am, wrapped in jackets and blankets against the cold and drizzle.

The winner needs one vote more than 50%, and at least a quarter of the vote in 24 of Kenya's 47 counties.