KABUL — The best thing that can be said about Afghanistan’s parliamentary election Saturday was that it took place at all.

Beyond that, the eagerly awaited and long-postponed poll — the first held without massive foreign assistance and supervision since the end of Taliban rule in 2001 — was an exercise in chaos, marred by violence.

About 5 p.m., Kabul police said, a suicide bomber attempted to enter a polling station on the northern outskirts of the capital, then detonated his explosives when police tried to stop him, killing at least 10 civilian voters and five police officers. 

Elsewhere in the capital, a loud afternoon explosion near a large apartment complex did little damage but sent hundreds of panicked voters running.

The Taliban, which had promised to disrupt the vote, claimed to have staged 164 attacks nationwide Saturday. In the days leading up to the poll, insurgents assassinated a top security official in Kandahar province, leading authorities to postpone the election there for one week at least. In other provinces, 10 candidates were killed during the campaign.

More than 8 million voters had registered to choose among about 2,500 candidates running for 249 seats in the lower house of parliament. The long list of hopefuls included 400 women, clean-cut young men in business suits and bearded older men in turbans.

The poll was seen as a crucial test, ahead of planned presidential elections next spring, and an important democratic milestone in a nation yearning for normalcy. Officials knew violence and fraud were likely, but there was a tacit consensus among Afghan leaders and their foreign backers that a reasonably fair and nonviolent polling day should be considered a success.

In the capital and across the country, however, many polls opened hours late and some not at all. People waited in lines all morning and gave up. Many who managed to cast votes described scenes of frenzied confusion and disorganization, with ballot boxes missing and names recorded wrong. A biometric ID system, installed at the last minute to reduce fraud, confounded unprepared poll workers and in many cases did not work.

“It’s a mess in there,” said a gray-haired laborer named Rahmatullah Ahmadzadi as he strode angrily out of a west Kabul polling station around 10 a.m. His voice shook as he held up his index finger dipped in purple ink. “There are 5,000 people registered at this spot, and only 100 have gotten to vote.”

The head of the Free and Fair Election Forum of Afghanistan, Mohammad Yousuf Rasheed, said the monitoring group was “pleased that people wanted to come out and vote despite the security threats, but we were disappointed to see the lack of preparation by the election commission staff and the threats by local power brokers in some provinces that influenced people to vote for them.”

Rasheed said that his observer teams had witnessed armed attacks by Taliban fighters on polling places in several provinces, including Faryab, Logar and Herat, and that some of those team members had been injured. 

Across the capital Saturday, streets were blocked off, and armed security forces were stationed at many intersections and outside every polling place. There was almost no traffic, and most people walked to schools or mosques in their neighborhoods to vote.

At midmorning, President Ashraf Ghani voted at a high school under tight security with his wife, Rula, at his side. He later declared, “Today, we proved together we will uphold democracy, casting ballots without fear.”

Many voters expressed strong enthusiasm for the election, which they described as a chance to bring fresh faces and new ideas to the political arena. First-time voters seemed especially excited, despite encountering the same frustrations as others when they attempted to vote.

“The lines are much too long, but I will not leave without voting,” said Abdul Ghafour, 43, a security guard who was waiting across the street from a long line of male voters that did not seem to move at all. Women voted at separate sites. 

“Our country needs new people in power,” Ghafour added. “I have a candidate I like. He has a master’s degree and speaks eight languages. It is worth the wait.”

But frustration mounted as the hours passed and the pace of vote processing did not increase. On social media and radio call-in shows, people in far-flung provinces complained of similar problems. In Herat, a man waited four hours for poll workers to find his name. In Konar, a polling place ran out of indelible ink. In Qarabagh, a town north of Kabul, voters blocked the highway in protest after election materials failed to arrive by midday.

One joke circulating on social media suggested that more people would be deprived of voting in so-called safe areas than in regions under Taliban control, where the danger forced hundreds of polling stations to be shuttered in advance. Voting was also canceled in Ghazni province, where the capital city is still recovering from a four-day Taliban siege last month.

By late afternoon, dozens of polling stations had still not opened in Kabul, and election officials announced that voting in some areas would be extended until 8 p.m. and possibly into Sunday. The officials said, however, that only 360 polling centers out of 4,900 had experienced major problems.

In a statement Saturday night, United Nations officials in Kabul said it is now “imperative” that Afghan authorities do everything possible to ensure that all voters “are given a reasonable opportunity” to cast a ballot and that they work to safeguard and complete the process of counting and announcing the results. The last national election, a fraud-plagued presidential poll in 2014, ended with no clear winner and an uneasy power-sharing government.

The violence-driven delay in voting in Kandahar, plus likely delays in Kabul and elsewhere due to technical problems, suggested that results would trickle in for weeks, face suspicion and disputes, and probably not be announced for at least a month.

Sayed Salahuddin and Sharif Hassan contributed to this report.