Afghan President Hamid Karzai had finished his speech at the National Day parade, marking 16 years since Kabul was captured from the Soviet-backed government, when shots were heard.
Troops in ceremonial dress were caught off guard by the by automatic weapons fire, which has been claimed by Taleban militants.
In the ensuing chaos, many troops fled the scene.
Journalists were among those forced to take cover. State TV stopped its live coverage of the event.
Some dived to the ground to avoid bullets.
But security forces regained control, arresting several attackers.
The parade is the largest in the Afghan military calendar.
Mr Karzai saluted dignitaries, minutes before they were targeted.