Voting was largely peaceful in Afghanistan's presidential election, with only isolated attacks on polling stations as a country racked by decades of violence embarked on its first democratic transfer of power.

A roadside bomb killed two policemen and wounded two others in the southern city of Qalat as they were returning from a polling station, while four voters were wounded in an explosion at a voting centre in the southeastern province of Logar.

There were no reports of more serious attacks on an election the Taliban had vowed to derail, branding it a US-backed sham, but many voters remained determined to make their voice heard. "I am here to vote and I am not afraid of any attacks," said Haji Ramazan as he stood in line at a polling station in rain-soaked Kabul. "This is my right, and no-one can stop me."

The Taliban had warned voters they would be targeted, and dozens had died in a spate of attacks in recent weeks. "The people of Afghanistan must answer the enemy's violence by using their vote," said interior minister Umer Daudzai on Twitter as voting began. "By casting your vote you reject fighting and confirm the peace."

The US, having spent $90 billion on training Afghan security forces since it helped depose the Taliban in 2001, could claim the election as evidence of a more democratic country. But the abiding Taliban threat and uncertainty over neighbouring Pakistan's intentions leave the worry that the country could enter a fresh cycle of violence and again become a haven for al-Qaeda and others, once the bulk of US troops have left by the year's end.

Most people expect the election to be better run than the chaotic 2009 vote that gave the outgoing Hamid Karzai a second term amid massive fraud and ballot stuffing.

One major concern is that it could take several months for a winner to be declared at a time when the country desperately needs a leader to stem rising violence as foreign troops prepare to leave.

About 12 million are eligible to cast votes for eight candidates, with former foreign ministers Abdullah Abdullah and Zalmai Rassoul, and former finance minister Ashraf Ghani the favourites.

While the constitution bars Karzai from running for the presidency again, after 12 years in power he is expected to retain influence.

More than 350,000 Afghan troops were deployed to guard polling stations, some of which suffered complaints from voters that they had run out of ballot papers.

The capital, Kabul, was sealed off by rings of roadblocks and checkpoints. In Kandahar, cradle of the Taliban insurgency, the mood was tense. Vehicles were not allowed to move on roads and checkpoints were set up at every intersection.

Hamida, a 20-year-old teacher working at a Kandahar polling station, said more than a dozen women turned up in the first two hours of voting and said she expected more, despite Taliban threats. "We are trying not to think about it," she said, only her eyes visible through her black niqab.

Raising questions about the legitimacy of the vote even before it began, the election commission had announced that at least 10% of polling stations were expected to be shut due to security threats.

The interior ministry said six officials, including an intelligence agent, were detained for trying to rig the vote, and elsewhere several people were arrested for trying to use fake voter cards.