text: This time the poll was held under a new constitution, designed to prevent a repeat of that violence when more than 1,000 people died when supporters of rival candidates clashed.
  They have been choosing a president, members of parliament and senators, the new posts of county governors and members of county assemblies. The presidential contest is seen as a two-horse race between Prime Minister Raila Odinga against Deputy Prime Minister Uhuru Kenyatta.
  BBC correspondents around the country sum up how the voting went.
  The queues in some places stretched for more than a kilometre, as voters in Kibera stood patiently in line.
  The neighbourhood is one of Nairobi's largest slums. It is the constituency of Raila Odinga, one of the favourites for the presidential contest and the scene of some of the worst violence following the last election in 2007.
  Today, many had arrived before dawn, waiting patiently in line, sometimes for hours.
  Voters cast their ballots into colour-coded boxes - six each - for a variety of different representatives, local and national.
  The memories of five years ago are still fresh and, as the campaign drew to a close, a sense of apprehension was palpable.
  Police talked of conspiracies to cause chaos and warned that violence would be met in kind.
  But, in Kibera at least, as the sun grew hotter and the umbrellas came out, the mood was up-beat.
  "Peace, peace," one crowd shouted as a truck of paramilitary police trundled past.
  We came across a man with dreadlocks and a pot of white paint. His message, "Peace wanted alive", can be seen daubed on walls and roads around the neighbourhood.
  The real test of peace, though, is likely to come once all the ballots have been cast, and the results start coming in.
  As the sun begins to set, the heat is easing and some polling stations are still open after the official closing time of 17:00, with queues of people determined to cast their vote.
  Tensions have been running high in this insecure and arid region near the Somali border and there has been a heavy security presence at the polling stations - with between five and 10 armed police officers on guard.
  On Sunday night one people died in an explosion and another person was shot dead in what is believed to be election-related violence.
  Some people began queuing at 05:00 - an hour before the polls opened.
  But there has been frustration in the long queues, with some buying water to pour over their heads to cool themselves down and others sitting under umbrellas.
  The biometric voter ID systems have not worked at the polling stations in this north-eastern town so electoral officials have had to resort to the manual voters registers. The computerised fingerprint and facial identification was introduced after the last election to prevent fraud.
  This slowed the whole process down, as has the fact that about 60% of voters have needed assistance to cast their ballot as they are illiterate.
  One woman with a baby on her back told me that after waiting until she got to the front of the queue, she found her name was not on the roll, even though she had a voter registration card.
  Hundreds of people ended up giving up.
  One man who could not find his name after lining up in three queues over 12 hours told me he was going home without voting.
  In the centre of Mombasa many people lined up from 05:00 to ensure their place in the queue and avoid the sweltering temperatures that characterise the coast.
  A cluster of white gazebos went some way to protect the early voters from the sun and the six colour-coded ballot boxes that sheltered beneath.
  Nearly half a million voters are registered in Kenya's second city, with another half a million making up the surrounding counties.
  This is historically "opposition" territory but under the complex arithmetic of the presidential vote, the candidates cannot afford to ignore this part of the country.
  Many voters queuing patiently described it as an "historic day" - the first time Kenyans are voting under a new constitution.
  But further along the coast, election day was marred by technical hitches and sporadic violence in a handful of flashpoints.
  Faulty biometric voting kits caused delays in Mombasa West.
  In Changamwe, half an hour's drive from the city, four police officers were hacked to death with machetes by a gang, who the authorities claim were members of the separatist Mombasa Revolutionary Council (MRC).
  The group had urged voters to boycott the polls in protest at what they see as the marginalisation of Mombasa, but few seemed to heed that call.
  The crowds outside Changamwe's main polling station had swollen to several hundred by midafternoon: Women with their babies strapped to their backs and men with beads of sweat running down their brow, seemingly undeterred by the attack that took place shortly before polls opened.
  Many people in the crowd outside Changamwe Social Hall which was turned into the local polling station seemed unconvinced that the group was to blame.
  Kenya has had a long history of violent elections and areas deemed to be opposition strongholds like this, are used to what people describe as "powerful forces" seeking to scare people away from the polls. But this time there is a palpable determination to prove to the world that Kenya is on a new democratic path.
  A whistle stop tour by the new Inspector General of police to the "scene of the crime" helped to provide reassurance in what has otherwise been a peaceful poll.
  Too busy tweeting to vote?
  Q&A: Kenya’s 2013 elections
  In pictures: Kenyan elections
  There were also disturbances in the town of Kilifi, where two civilians were among six shot dead.
  Although the violence that flared up was in isolated areas, it got Khalef Kalifa from Muslims for Human Rights anxious.As an election observer he said police seemed "ill prepared" for any clashes and that in some polling stations computers were not working and "in one polling station a voter had to come and show the presiding offer how to use the computer".
  But election officials promised voters they would keep the polling stations open to compensate for earlier delays.
  By the time the evening call to prayer could bear heard echoing out from the mosques of Mombasa, Festus Mwanzia was number 27 in the queue.  He had waited patiently in line for nearly 12 hours.
  "I'll be home by 10," he chirped confidently. "Just in time to catch the results on TV."
  Many people here know the biggest test is yet to come once the tallying gets under way.
  In the western town of Eldoret, the provincial capital of the Rift Valley where much of the post-election violence occurred following the December 2007 election, voting started early in the morning with enthusiastic voters arriving as early as 05:00.
  There were long queues, some stretching for a kilometre.
  At the MV Patel polling station which has the highest number of registered voters in the region, people complained that the process was too slow.
  In Shinyalu, in the rural Kakamega district - between Eldoret and Kisumu - the area's former member of parliament, Justus Kizito, was ambushed in the early hours of the morning and his Range Rover was burnt to ashes.
  He says the attack was political and forced to flee for fear of his life before the mob set the vehicle on fire.
  At Kosachei Primary School near Eldoret, William Ruto, a suspect at the International Criminal Court from the Kalenjin community and running mate to presidential candidate and fellow indictee Uhuru Kenyatta, a Kikuyu, cast his vote at 07:30.
  Afterwards he told me that should their Jubilee coalition win, they would co-operate with the ICC in the hope of clearing their names. The two, who were rivals during the last poll, both deny charges of orchestrating the violence following the 2007 vote.
  At the Kiambaa polling station - just a stone's throw from the ill-fated church where more than 40 Kikuyu people who had sought shelter there were burnt alive on 1 January 2008, when it was set ablaze by a mob of armed Kalenjin youth - most voters were happy to have cast their ballots in peace.
  Paty Chelegat, a Kalenjin mother of two, told the BBC: "There is peace in Kiambaa area and indeed the entire Uasin Gishu county and my joy is that I have voted peacefully and [I am] hoping that all will be well even after the results are announced."
  Peter Kariuki, a father of four, said despite losing his relatives in the Kiambaa church fire, he is encouraged with the prevailing peace existing among the various communities that used not to see eye to eye.
  "I am very happy because this vote is a new beginning to residents of Kiambaa and Eldoret," he said.
  I was awoken in this lakeside city, a stronghold of presidential candidate Raila Odinga, at 02:15 by people blowing vuvuzelas - their alarm call to get people down to the polling stations early.
  By 04:00 - two hours before the polls opened - thousands of people were already queuing.
  There was a little tension at one polling station when it did not open on time and voters forced the gate open, but officials restored order and voting began.
  Women with babies or who were pregnant were able to get to the front on the winding line.
  At one polling station a woman stuffed a baby blanket under her dress so that she could pass for pregnant and be given priority to vote, but her belly ruse did not work.
  After that women in the slum of Kondele were asked to breastfeed their children to prove the offspring are theirs in order to jump the queues.
  Kondele, where there are high rates of unemployment, has a history of electoral violence with rival local politicians often using youths to cause trouble.
  A 56-year-old man in Kondele told me it was the first time he had ever witnessed a peaceful election in the slum.
  Mr Odinga's Cord alliance has been urging people not to drink alcohol and on the eve of the vote most bars in Kisumu were closed.
  The majority of businesses have also been shut today and after voting people followed advice to go home instead of hanging around in groups to watch the proceedings.
  It is hard to believe given the huge crowds earlier on but electoral officials in Kondele were already tallying the votes just an hour after the polls were due to close at 17:00.
  After being counted, the ballots will be taken to a central place in the city before being transferred to Nairobi.
  People came out in huge numbers to vote, some queuing in the chilly morning from 03:00.
  There were complaints about the slow process of casting the six ballots, but voters remained jovial.
  "I've waited five hours - I can wait 50 more," one man told me.
  "I will not leave before voting, come rain, sun, hunger or sleep."
  Nakuru is a cosmopolitan area, though it turned into an ethnic battle field between two rival communities, the Kalenjins and Kikuyus, after the last election.
  "We will redeem the image of Nakuru, what happened in 2007 will not happen again. We have learnt our lesson," a 29-year-old woman told me.
  Some people travelled long distances to vote, one man at the Afraha stadium - where the line was twice the length of a football pitch - had returned home from Uganda where he works.
  The biometric ID systems malfunctioned at most polling stations, which caused delays.
  One person, who joined a queue at 03:00 eventually voted at 11:00 because he was searching for his name on the paper voters' register - it was only at the front of the third queue that he was eventually successful.
  Despite the delays, everyone got a chance to vote and polling stations closed as planned at 17:00 local time (14:00 GMT).
  Most people have returned home, to follow the counting process on TV or radio.
  The usually busy city centre is deserted, with no cars or pedestrians.
  Even the curio stalls popular with tourists coming to see the flamingos at nearby Lake Nakuru are closed.
  I came across only one restaurant that is open.
  Trucks full of police can be seen patrolling everywhere in this town - an agricultural centre in the Rift Valley.
  But people I spoke to say they do not expect any violence once results come out, as efforts to achieve reconciliation between communities that were pitted against each other after the 2007 election have been successful.
target: Kenyans have been voting in a key election - the first since the disputed contest of December 2007 that triggered weeks of bloodshed.