NAIROBI (AFP) - Long lines of Kenyans queued from way before dawn to vote Monday in the first election since the violence-wracked polls five years ago, with a deadly police ambush hours before polling started marring the key ballot.

The tense elections are seen as a crucial test for Kenya, with leaders vowing to avoid a repeat of the bloody 2007-8 post-poll violence in which over 1,100 people were killed and observers repeatedly warning of the risk of renewed conflict.

Voters standing for hours in snaking lines several hundreds of metres (yards) long - and several people thick - crowded peacefully outside polling stations to take part in one of the most complex elections Kenya has ever held.

People began lining up outside polling stations from as early as 4:00 am (0100 GMT) to cast their votes, two hours ahead of the official opening of the polls.

In middle-class areas of Nairobi, parked cars blocked the streets around polling stations, with progress slow in some centres due to delays due to malfunctioning electronic registration equipment.

Ahmed Issack Hassan, Independent Electoral and Boundaries Commission (IEBC) chairman, said he was “aware of the challenges faced in various parts of the country” and were addressing them, appealing for voters to “be patient”.

Tensions were high on the coast including in the port city of Mombasa where six policemen killed in two separate attacks, including an ambush by some 200 youths armed with guns and bows and arrows, hours before the opening of polling stations.

“Six policemen and six attackers were killed during the confrontation,” Kenyan police chief David Kimaiyo told reporters, adding that 400 officers were being sent to the coastal province to beef up security.

Kimaiyo said the attackers were suspected members of the Mombasa Republican Council (MRC), a group seeking the secession of the coastal region popular with tourists.

Police have blamed the MRC for a string of attacks last year, and the group had threatened to boycott the polls.

Despite the attack, voters packed the streets in the city.

“We are not worried, we are voting,” said architect Said Said, waiting to cast a ballot at a primary school.

The Kenya National Commission on Human Rights said the attacks “were coordinated and aimed at interrupting voting in these areas.”

A remote-controlled bomb was also set off in the northeastern town of Mandera - a town on the border with war-torn Somalia where Kenyan troops are battling Al-Qaeda linked insurgents - but resulted in no casualties, police said. - Slow progress but calm queues -

Polling stations were supposed to close at 5:00pm but anyone in the queue by closing time will be allowed to vote. A polling station that opened one hour late will stay open for an extra hour, electoral officials said.

Neck-and-neck rivals for the presidency, Prime Minister Raila Odinga and his deputy Uhuru Kenyatta, have publicly vowed there will be no repeat of the bloodshed that followed the disputed 2007 polls.

Crimes against humanity trials later this year at The Hague-based International Criminal Court (ICC) for Kenyatta and running mate William Ruto have raised the stakes: should they win the vote, the president and vice-president could be absent on trial for years.

Both front-runners have said they are confident of winning the absolute majority needed to avoid a second round run off vote. “We can win these elections in the first round... At the end of the day we will definitely be declared the winner,” Odinga said after voting in Nairobi’s Kibera shanty town, the scene of some of the worst ethnic clashes after the 2007 poll.

Kenyatta, voting in his hometown of Gatundu some 90 kilometres (55 miles) north of Nairobi, said he was “ready and prepared for whatever outcome” Kenyans chose.

Kenyans are casting six ballots, voting for a new president, parliamentarians, governors, senators, councillors and special women’s representatives, with some 14.3 million registered voters and more than 30,000 polling stations.

Preliminary results are expected within 48 hours but could take up to seven days, officials have said.

Around 100,000 police have been deployed to ensure the election is peaceful, and about 23,000 observers, including 2,600 international monitors, are watching the vote, officials say.

In the western town of Kisumu - the heartland of Odinga supporters who went on the rampage in 2007-2008 after he was controversially pipped to the top job by President Mwai Kibaki - people blew whistles and sang as they waited to vote.

“We slept here last night because we want real change and we want our candidate - Raila,” said Susan Morell, 30. “We want real change but we want peace. We will accept the result as it comes out because we are sure of winning.”

The 2007-2008 violence exposed widespread disenchantment with the political class, deep tribal divisions and shattered Kenya’s image as a beacon of regional stability.

More checks are in place this time to limit vote rigging, while a new constitution devolving powers has made the poll less of a winner-take-all race.