Women help to swell the presidential election turnout to seven million, despite violence and reports of fraud and threats in the countryside

In anxious preparation for a historic presidential election, Afghanistan fortified its cities against attack, primed observers to detect fraud ... then was blind-sided by a problem no one had even dared to imagine – unprecedented voter enthusiasm.

Defying Taliban threats and the more mundane challenge of rainy weather, Afghans flocked to the polls in such high numbers that ballots were running out in some places by midday. Soon, more than a third of provinces were reporting shortfalls, and as the scale of the problem emerged election organisers scrambled to respond.

"I don't know how I will bear it if I don't get to vote," said 22-year-old Atifa Sultani, who had her finger marked with indelible ink – designed to stop repeat voting – at a station in west Kabul before being told that ballots had run out. "As a citizen it's my right to choose our leader, but I can't try anywhere else, because from my finger it seems I already voted."

Afghans are choosing a successor to President Hamid Karzai after 12 years, and if the handover is smooth it will be the first peaceful, democratic transfer of power their country has ever seen.

For months Kabul was filled with rumours that Karzai would seek to delay or cancel the vote so that he could hold on to power. But he kept his promises to hold the poll on time with an early-morning trip to a polling station near his palace.

"Today is a vital day for us, the people of Afghanistan, that will determine our future," he said after casting his ballot and urged other voters to come out . They did so in numbers and with a determination that surprised even optimists, and even after ballots ran out. Seven million Afghans cast votes, said election organisers, nearly two and a half million more than the last presidential poll, and about 60% of all eligible voters.

In the Kabul station that ran out of ballots, Sultani waited three hours until a last-minute batch arrived, sending organisers who had been muttering darkly about government conspiracies scrambling to reassemble the polling station.

A 77-year-old man who had ignored family warnings about going out in the rain was first in line. "It is my joy to vote," Qamber Ali said, echoing the sentiments of thousands who stood patiently in well-disciplined lines even through downpours. Younger voters posed for photos with their inked fingers and uploaded them to Facebook and Twitter. "Have voted for the future of my country," wrote artist Shamsia Hassani. Hassani was joined by hundreds of thousands of other women, many students and professionals who have come of age during Karzai's rule and were voting for the first time. Ballots ran out particularly fast at voting centres for women, who also made up more candidates than ever before.

Male and female polling stations are separate because many in the conservative country frown on the mingling of the sexes in any context outside of the family. "Of course the massive turnout of women voters is a big slap to all those who want to block us to contribute. Feeling proud to be a woman," said activist Samira Huria, who had returned to Afghanistan to take part in the poll.

It was not all good news. The election in some rural areas dominated by insurgents sounded like another vote entirely, with villagers steering clear of voting stations after the Taliban warned them to stay away, commanders taking ballot-boxes to stuff at their leisure, and rocket, bomb and gun attacks.

At least one person was killed, several others injured and more than 200 polling stations closed at the last minute because of security threats. But multiple rings of tight security, with Kabul virtually shut down for days before the election, appear to have prevented any major Taliban attacks.

The insurgents had denounced the elections as a sham, warned that anyone who worked on them or took part was risking their lives, and mounted a high-profile campaign of attacks in the runup to the vote. The bloodshed cut short some international election monitoring missions and prompted many foreigners to evacuate ahead of the poll. In Kabul a lone gunmen shot dead nine people, including a prominent Afghan journalist and his wife and two young children as they ate dinner in a city centre hotel, stormed the guesthouse of a landmine removal charity, and attacked two election offices and a ministry in less than two weeks.

Afghan intelligence sources said several squads of suicide attackers were preparing more spectacular attacks on polling day. In response the government declared four days of holiday, sent workers home, shut down all roads into the city and promised people it would guarantee their safety with more than 300,000 police and soldiers deployed around the country.

Kabul voters spooked by the string of attacks said they were unsure if the security cordon would hold but had come to the polls anyway. "I am 100% worried about security, but this is about the destiny of our country," said 23-year-old Aslan, an election monitor who by 10am had already spotted a man who had scrubbed his inked finger and was trying to vote twice.

He was part of a 200,000-strong squad of election observers, mostly tied to individual candidates, who kept a far closer eye on polling than five years ago when the vote that returned Karzai to power was marred by widespread fraud and more than a million ballots were thrown out.

It would be foolish to call the election overall a success at this stage. Reports of fraud in 2009 trickled in slowly at first, and even if this poll proves cleaner there is certain to be controversy about which areas were short of ballots, and whether it affected some candidates more than others.

Election organisers reacted fast to the high turnout, extending voting hours, sending out more ballots, and trying to explain their miscalculation to the angry masses of would-be voters. "We surveyed each area, and sent ballot papers based on population," said Ziaul Haq Amarkhil, chief electoral officer for the Independent Election Commission. "If we had sent more papers everywhere [to start with], it could have offered opportunity for fraud."

Not all the shortages were resolved, though, and monitors said they would investigate whether any stations ran out because of early-morning ballot-box stuffing. Any complaints will certainly be joined by other cases of abuse. Officials have already made arrests for attempted ballot-box stuffing and voter fraud, when four people were found with over 1,000 voter identity cards.

Even if results are declared clean, they will only be final if one candidate gets more than 50% of the vote. Anything lower triggers a second round runoff, and with strong competition between the top three candidates another polling day seems more likely than not.

Still, Afghans celebrated their extraordinary success in holding a day of voting where the focus stayed mostly on people casting their ballots, not the ones trying to stop them.

"Huge, huge day for Afghanistan. A historic event ends peacefully with millions casting their votes," said Saad Mohseni, the businessman owner of Tolo TV, one of the country's biggest channels. "A massive victory for our people, and a massive kick in the face for the Taliban."

Mokhtar Amiri contributed to this report