Afghans have voted in the country's second presidential election since the fall of the Taliban in 2001.
The vote passed off without major violence, despite sporadic attacks by Taliban who had vowed to disrupt it.
Reports suggest turnout was patchy - although polling was extended. Fewer people voted in the south, where militant influence is greater.
President Hamid Karzai, running for a second term, faces competition from dozens of rivals.
Polls officially closed at 1700 (1230 GMT), after being kept open for an extra hour.
The election follows a lively campaign period in which dozens of candidates vied for the presidency - but it was marred by violent attacks and frequent complaints of pre-election corruption and fraud.
Some 300,000 Afghan and international troops were on patrol to prevent attacks.
Violent incidents around the country included:
Taliban militants stormed a town in Baghlan, northern Afghanistan, preventing polling stations from opening, police tell AFP news agency. At least eight died in ensuing clashes with police
Taliban militants set fire to a bus on the Kandahar-Kabul highway in Ghazni, after offloading passengers and the driver, reportedly as punishment for violating a Taliban ban on using the road
Rockets hitting houses in Khost and Kandahar provinces killed two women and several children
Also in Khost, a civilian car hit a roadside bomb, killing one person and injuring three
Two suicide bombers on a motorbike in Gardez, Paktia province, were killed before hitting their target, police said
In northern Baghlan province, a district police chief was killed when Taliban militants attacked a police post
In Kabul, the bodies of two alleged militants were recovered after a gun battle with police in a residential district - police said they were suicide bombers but it is unclear whether they blew themselves up or were shot dead.
The polls - which also see voters electing members to provincial councils - are the first organised primarily by Afghans themselves.
17 million eligible voters
Polls opened at 0700 (0230 GMT) and close at 1600
As well as presidential polls, voters choosing between 3,000 candidates for 420 seats in provincial councils
Official preliminary results not expected for two weeks but may be earlier indications
300,000 troops on patrol (including 100,000 foreign troops)
250,000 observers and journalists
First polls organised by Afghans themselves, but with international support
The vast majority of the country's 6,969 polling stations were able to open despite the security threat, the UN said.
Speaking on state TV, the director of Afghanistan's Independent Election Commission, Azizullah Loudin, claimed turnout had been "high".
Apart from the earlier gun battle in Kabul, the city was mainly reported to be quiet, with a brisk turnout in some polling stations while there was little activity in others.
Despite repeated blasts being heard in Lashkar Gah, the provincial capital of militant stronghold Helmand province, lots of voters were coming out, though in next-door Kandahar turnout appeared to be low.
And in Jalalabad, eastern Nangarhar province, some districts reported no voters at all.
AT THE SCENE
Caroline Wyatt, BBC News, Lashkar Gah, Helmand province
We went out to polling stations as they opened in Lashkar Gah this morning and the first thing that happened was a loud explosion could be heard near the governor's compound.
We were told to get down, to get into safety. After that we went back out and we heard in total six other explosions until about 0830.
I had presumed that would mean people would be less keen to vote. I was wrong. We went to a high school, one of the men's voting centres. There were queues coming out of every room. People we spoke to were extremely enthusiastic about voting. They were all supporters of President Hamid Karzai.
They said they were not scared by the Taliban's threat to chop off their fingers if they were found with ink showing that they voted, and they were not scared by the Taliban's bombs and rockets.
The BBC's Martin Patience points out that three-quarters of Afghans live in the country's 30,000 rural villages - so it is turnout in the countryside which is key.
A voter in Kabul said she hoped the election would bring security to Afghanistan.
"We want the next president to stop the killing of innocent people and to find jobs for the people, and bring peace."
But other would-be voters said they feared for their safety, while yet others said they had little faith in Afghan democracy.
"Unfortunately, democracy has been exported to Afghanistan, it hasn't grown up from the bottom to the top," said one.
"We are hoping that the United Nations and the rest of the world's powers should pay attention to this to help the Afghan people to grow democracy from the inside."
Across the country, some 17 million Afghans were eligible to vote.
There were widespread concerns about corruption in the run-up to the poll, with reports of voting cards being openly sold and of candidates offering large bribes.
The government was criticised for imposing a ban on election-day coverage of violence incidents, saying it did not want to deter voters.
Two BBC reporters were among a group of journalists briefly detained and questioned by police in Kabul on Thursday for violating the ban.
Some had videotapes confiscated before being released.
'Day of hope'
Opinion polls put support for Hamid Karzai, one of more than 30 candidates, at about 45%, with his former Foreign Minister, Abdullah Abdullah, in second place with 25%.
His other two main opponents are the independent candidate Ashraf Ghani Ahmadzai and ex-World Bank official Ramazan Bashardost.
This will be for peace, for progress, and for the well-being of the Afghan people
This page is best viewed in an up-to-date web browser with style sheets (CSS) enabled. While you will be able to view the content of this page in your current browser, you will not be able to get the full visual experience. Please consider upgrading your browser software or enabling style sheets (CSS) if you are able to do so.