People in Afghanistan have voted for a new president in the nation's first transfer of power via the ballot box.
Turnout was brisk despite heavy rain, but there are reports of ballot paper shortages and sporadic violence.
A massive operation was launched to thwart the Taliban, who had vowed to disrupt the election.
Eight candidates are vying to succeed Hamid Karzai, who is barred by the constitution from seeking a third consecutive term as president.
The secretary of the Afghan Independent Electoral Commission (IEC), Ziaul Haq Amarkhel, said that by 17:00 local time, when the polls had officially closed, seven million people out of an estimated eligible 12 million had voted.
He told the BBC that people who were standing in queues outside polling stations at official closing time would be allowed to cast their votes.
Asked to comment on widespread reports of polling stations running out of ballot papers, he said this information was "false".
But BBC correspondents are continuing to get reports of polling centres running out of ballots hours before the polls closed in many areas including Kabul, northern Takhar province, north-eastern Badakhshan province, eastern Paktia province, and Nimroz province in the south-west - where one man, Abdul Ahad, said he and 15 family members had been to every polling centre in their district in an attempt to vote, but all of them had run out of ballot papers.
The biggest military operation since the fall of the Taliban in 2001 was rolled out for the vote, says the BBC's David Loyn in the Afghan capital. All 400,000 of Afghanistan's police and soldiers were said to be on duty for the election.
Traffic was prevented from entering the Afghan capital from midday on Friday, with police checkpoints erected at every junction.
However, in parts of the capital voters could be seen queuing an hour before polls opened and there was a good-natured, almost carnival atmosphere, with many people on the streets, our correspondent reports.
Across the country, 10% of stations declared unsafe to open by the election commission.
The Afghan ministry of defence said three major incidents had taken place on polling day:
- Three IEC staff and three Afghan military personnel were killed in a Taliban rocket attack on a polling centre in the north-eastern province of Kunduz
- Twelve insurgents were killed and nine others injured in a battle between the Afghan national army and insurgents in the north-western province of Badqhis
- An Afghan soldier was killed in the eastern province of Logar
Fears of fraud, which have marred previous polls in Afghanistan, resurfaced with reports from the southern province of Kandahar that police were preventing voters and observers from reaching polling stations.
The interior ministry said two police officers were arrested in Wardak province for stuffing ballot boxes.
Concerns were also raised before the poll about the possible presence of "ghost" polling stations as well as the fact that the number of election cards in circulation appeared to be vastly more than the number of registered voters.
Many women took part in the polls, although not in the same numbers as men.
"I'm not afraid of Taliban threats, we will die one day anyway. I want my vote to be a slap in the face of the Taliban," Kabul housewife Laila Neyazi told AFP news agency.
There are eight candidates for president, but three are considered frontrunners - former foreign ministers Abdullah Abdullah and Zalmai Rassoul, and former Finance Minister Ashraf Ghani Ahmadzai.
Dr Abdullah has fought a polished campaign, Mr Ghani has strong support among the new urban youth vote and Dr Rassoul is believed to favoured by Hamid Karzai, our correspondent says.
However, no candidate is expected to secure more than the 50% of the vote needed to be the outright winner, which means there is likely to be a second round run-off on 28 May.
In the latest in a string of deadly attacks that marred the lead-up to the election, award-winning German photographer Anja Niedringhaus was killed and veteran Canadian reporter Kathy Gannon was injured when a police commander opened fire on their car in the eastern town of Khost on Friday.
Interior Minister Omar Daudzai told the BBC that the man being held over the shooting might have acted under the influence of "stress" and added he thought it was a "one-off incident" unconnected to the Taliban.
The run-up to the historic poll has been the bloodiest since the fall of the Taliban, says the BBC's Lyse Doucet in Kabul.
The heavily guarded interior ministry, the main compound of the IEC and the five-star Serena Hotel, popular with foreigners, have all been attacked.