Mattis commented on the attack in Kandahar during a break in meetings at an Asian security conference in Singapore.
Mattis called the death of Abdul Raziq a "tragic loss of a patriot." But he said he believes the Afghan security forces have matured to the point where they can continue fighting the Taliban without him.
"We remain absolutely committed to an Afghan-led Afghan reconciliation," he said. "Right now, we're going toward the election and we will continue to defend the Afghan people."
He said he had not spoken to the top U.S. commander in Afghanistan, Gen. Scott Miller, since the attack. Miller was present during the shooting but uninjured. Mattis said it's unclear how the attack will affect voter turnout in Saturday's parliamentary elections.
"Terrorism can have a short-term effect," Mattis said. "I think it's too early to say whether it will have any real effect on the upcoming election. I'm not willing to say that right now."
Copyright 2018 The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed.