Kandahar's police chief, the provincial governor, and the local intelligence chief were among at least three killed in the shooting.
Mattis called the death of Gen. Raziq a "tragic loss of a patriot".
Peters said initial reports indicate one of the original attackers is dead.
North Atlantic Treaty Organisation officials said Miller was safe.
Gen. Harold J. Greene was killed and about a dozen US soldiers were wounded when an Afghan soldier opened fire inside a building in Kabul.
Two Americans, including one US service member, were wounded.
Gen. Scott Miller, the commander of US and North Atlantic Treaty Organisation forces in Afghanistan, was also attending, but survived uninjured, although a regional intelligence agency commander was killed and the provincial governor severely wounded.
Within hours of the attack, Afghan President Ashraf Ghani addressed the nation to assure Kandahar residents it was safe to go to the polls.
They said that a member of the governor's compound guard had opened fire on Raziq and that a shootout involving Afghan and American security personnel had ensued. The US military released a statement saying that Miller had not been hurt, but that three Americans had been injured.
"This killing is the most significant military victory for the Taliban in recent memory", said Graeme Smith, a consultant with the International Crisis Group.
A close ally of the USA military, Raziq, has been credited with pacifying large swaths of Kandahar but has been accused by human rights groups of gross human rights violations, including forcible disappearances, torture, and extrajudicial killings. The UN committee against torture in 2017 said that he should be prosecuted over allegations of torture and enforced disappearances.
In January a year ago, the visiting ambassador of the United Arab Emirates, five other UAE diplomats and some local officials were killed by explosives hidden in a government building in Kandahar.
More than 2,500 candidates are competing for 249 seats in the lower house, including doctors, mullahs, and the sons of former warlords.
The Americans were wounded in the cross-fire after gunfire erupted at the palace, Peters said.
The U.N. Security Council condemned the attacks and others recently in Afghanistan and said violence or threats meant to disrupt the elections were unacceptable.
The Taliban quickly claimed responsibility for the attack, which takes the number of candidates killed so far during the campaign season to at least 10.