KABUL, Afghanistan — Millions of Afghans were voting Saturday in parliamentary elections overshadowed by violence and dysfunction.

This week's deadly attack on senior Afghan officials underlined the profound challenges the country faces as it heads to the polls amid a growing threat from Taliban insurgents.

An elite guard of a provincial governor gunned down officials after a security meeting in Kandahar Thursday, killing the southern province's powerful police chief, Gen. Abdul Raziq, and intelligence chief Abdul Mohmin. The U.S. and NATO's top commander in the country, Gen. Scott Miller, had been attending a meeting with the men but escaped unharmed.

The Taliban claimed responsibility for the incident, providing photographs of the alleged attacker who they say contacted them months ago.

While the attack led to polls being postponed a week in Kandahar, government officials said that some areas would see voting extended by a day into Sunday after technical and organizational problems stopped voters casting their ballot in some polling centers.

North of Kabul, thousands of outraged voters blocked a road after waiting more than five hours for a polling station to open, said Mohammad Azim, the governor of Qarabagh district where the demonstration took place, the Associated Press reported.

Resurgent threat

Raziq's death was a blow to those seeking to beat back the militants and stand up to neighboring Pakistan, which has long been accused of meddling in Afghan affairs.

"I don't think anyone can replace him," said Dawa Khan Menapal, a parliamentary candidate and former spokesperson for President Ashraf Ghani. "He fought so hard to make Kandahar stable while the rest of the country was not safe."

Military personnel hold a photo of Gen. Abdul Raziq, Kandahar police chief during his burial ceremony on Friday. Raziq's death deals a powerful blow to the Afghan government's already flagging war against a resurgent Taliban. AP

While he was praised by some for bringing stability to Kandahar — considered the Taliban's spiritual home — human rights groups accused Raziq of widespread abuses.

The militants have been fighting American-led NATO forces since the U.S. invaded Afghanistan in pursuit of Osama bin Laden, the mastermind of the Sept. 11, 2001 attacks.

The group has seen a resurgence in recent years, and the first half of 2018 has been the deadliest on record in the drawn-out war with 1,692 civilians killed, according to the United Nations. More than 2,400 Americans have also died in the conflict.

President Donald Trump has said he wants to withdraw the approximately 14,000 American troops who remain in the country. Current and former U.S. officials told NBC News that Trump's impatience with the war prompted U.S. diplomats and commanders to kick-start peace negotiations earlier this year.

'Wiped out'

Thursday's attack contradicts claims that a degree of stability has been reached in Afghanistan after four decades of violence, said Aaditya Dave, an analyst with British think tank the Royal United Services Institute (RUSI).

"It is a blow to Kandahar because their whole security establishment, the top leadership, has been wiped out," Dave said.

Kandahar Governor Zalmay Wesa was initially reported to have been killed but the government later clarified he was wounded. Three people — a U.S. service member, an American civilian, and a NATO coalition contractor— were also injured.

Dave added the incident raises questions aboutthe viability of Saturday's parliamentary elections — the country's third since the Taliban were ousted by the U.S.-backed invasion in 2001.

The Taliban has been fighting to oust the government in Kabul since it was toppled. It has promised to try to disrupt the elections, which it views as illegitimate.

At least two candidates and over 34 civilians have been killed in such attacks since the 20-day campaign period began. Five other candidates were killed and two others were abducted in the lead-up.

Clashes also erupted between the Taliban and the security forces in at least three provinces.

Several incidents marred polling day on Saturday, with three police killed and at least eight people wounded by explosions in Kabul. Clashes also erupted between the Taliban and the security forces in at least three provinces.

The Taliban has made gains in recent years and is believed to threaten or control more than 40 percent of the country, according to an April report by the Special Inspector General for Afghanistan Reconstruction, a watchdog responsible for monitoring the American effort to rebuild the country.

Regardless of the violence and the Taliban's gains, American officials have urged Afghans to cast their vote.

A Taliban spokesman told NBC News that Miller was among the targets in the Thursday attack, although the general himself said he doubted that was the case. Muhammad Sadiq / EPA

Miller, the American general who survived the attack, encouraged Afghans to head to the polls.

“My message to the people of Afghanistan has been very consistent. You have every right to be proud of your security forces and the preparations they’ve made for this election,” he said on local television.

Defense Secretary Jim Mattis told reporters Friday that the U.S. remains "absolutely committed to an Afghan-led Afghan reconciliation."

"Right now," he said, "we're going toward the election and we will continue to defend the Afghan people."

U.S. Gen. Joseph Votel, commander of U.S. Central Command, on Saturday from CENTCOM’s forward headquarters in Doha, Qatar, expressed confidence that Afghan forces can provide security for the elections, and an attack like the one in Kandahar won’t change the security situation in the country.

"My assessment is the Afghans are resilient to this. No one wants to see this kind of stuff happen. But this is a feature of the fight that were involved in right here and these things are going to happen," he said.

"But in this case we think the Afghans are ready to provide the security that is needed for this election, the security they need going forward and we are committed to continuing to work with them to ensure they can do everything they need to do," Votel said.

Afghan officials also maintain that peace is drawing near for the country. President Ashraf Ghani, speaking at the funeral of slain Kandahar intelligence chief in Kabul on Friday, said the attack was a sign that the Taliban is losing ground.

"We can see the end of 40 years of conflict in Afghanistan, that is why our sworn enemies are attacking our brave sons," he said. "They won't be able to disturb us to achieve peace."

RUSI's Dave disagreed, saying Thursday's attack revealed the weakness of the U.S. and Afghan government's position.

"Many of the initiatives have been directed by presumptions that the government and the U.S. position is a lot stronger than it actually is on the ground," he said. "Maybe that will be recalibrated."

Ahmed Mengli reported from Kabul, Afghanistan; Mushtaq Yusufzai from Peshawar, Pakistan; Courtney Kube reported from Doha, Qatar; and Linda Givetash from London.