KANDAHAR, Afghanistan (Reuters) - General Abdul Razeq, one of Afghanistan’s most powerful security commanders, was killed on Thursday in a shooting attack by a bodyguard that dealt a severe blow to the Afghan government ahead of parliamentary elections on Saturday, officials said.

General Scott Miller, the top U.S. commander in Afghanistan who had been at a meeting with Razeq and the governor of the southern province of Kandahar only moments earlier, was not injured in the attack.

But Razeq, the Kandahar police commander, and the local head of the NDS intelligence service were both fatally wounded before the attacker was himself killed. Kandahar Governor Zalmay Wesa was severely wounded and contradictory reports about whether he had survived could not immediately be resolved.

Taliban militants claimed responsibility for the assault, which decapitated the security command in one of the country’s most strategically important and contested provinces.

The Taliban said they said they had targeted both Miller and Razeq, who had a fearsome reputation as a ruthless foe of the Islamist insurgents in their southern Afghan heartland.

Security officials had warned of likely attacks ahead of the election but the death of Razeq caused deep shock that officials fear may keep away voters, after Taliban warnings not to take part in what they consider a foreign-imposed ballot.

“General Razeq’s death will have a huge impact on security and the election in the south because a lot of voters may not feel safe to go to vote,” said a senior security official, who spoke on condition of anonymity.

The Taliban released a picture of a young man in military-style uniform who they said was the attacker and Afghan officials identified him by the name of Gulbuddin.

It remained unclear how the insurgents managed to infiltrate a gunman so close to such senior commanders.

Officials said Razeq, Miller and the other officials were walking toward a landing zone as the helicopter taking the U.S. general’s party back to Kabul approached to land when the gunman, who was waiting outside, opened fire on the group.

“Provincial officials including the governor, the police chief and other officials were accompanying the foreign guests to the aircraft when the gunshots happened,” said Said Jan Khakrezwal, the head of the provincial council.

The attack underlined how precarious the situation remains in Afghanistan even after Taliban and U.S. officials have opened preliminary contacts aimed at establishing the basis for future peace talks.

But a Pentagon spokesman said Washington remained committed to its strategy of maintaining heavy military pressure on the Taliban to force the insurgents to the negotiating table.

FILE PHOTO: Gen. Abdul Razeq, who was killed in today's attack, is seen at his office in Kandahar province, Afghanistan August 4, 2016. REUTERS/Stringer

“This attack will not change U.S. resolve in our South Asia strategy. If anything, it makes us more resolute,” U.S. Defense Department spokesman Lieutenant Colonel Kone Faulkner told Reuters.

BODY ARMOR

President Ashraf Ghani said a team led by the head of the NDS, Masoom Stanekzai, would be sent to Kandahar to bring the situation under control and investigate the incident, which sharply heightens security concerns around Saturday’s election.

At least two hand grenade explosions and sporadic gunfire from around the compound were also reported by officials, in a sign the attack was carefully coordinated.

The three Afghan officials were all hit in the fusillade from the gunman and two Americans and a coalition contractor were hit in the crossfire. But Miller, who took command of U.S. forces in Afghanistan and the NATO-led Resolute Support mission last month, was not harmed.

“The brutal police chief of Kandahar has been killed along several other officials,” a Taliban statement said.

A flamboyant commander, whose men wore badges bearing his name, Razeq had survived several attempts on his life over the years and narrowly escaped an attack last year in which five diplomats from the United Arab Emirates were killed in Kandahar.

A U.S. Embassy official said eyewitness reports indicated that claims Miller was a target in the attack were false, but he gave no detail.

Local officials said Miller appeared to have been saved by his body armor but there was no immediate confirmation from NATO headquarters.

Razeq was criticized by human rights groups but highly respected by U.S. officers who saw him as one of Afghanistan’s most effective commanders, largely responsible for keeping Kandahar under control.

Although technically only a police commander, he was a powerful political figure in his own right and had clashed repeatedly with Ghani in the past, using his unchallenged position in Kandahar to resist attempts to sack him.

A cameramen working for Afghanistan’s RTA state television was also killed on Thursday, according to the director of the Afghanistan journalists center, Ahmad Quraishi.