President Hamid Karzai, Cabinet ministers and ambassadors escaped unharmed from the assault on the event marking the 16th anniversary of the end of Soviet-backed rule in Afghanistan. A lawmaker seated about 30 yards from Karzai was among the dead.
Karzai appeared later on national television saying several suspects had been arrested. He blamed the attack on the "enemy of Afghanistan" and appealed for calm. About 100 people were rounded up for questioning, an Afghan intelligence official said.
A Taliban spokesman claimed responsibility for the attack. Six militants armed with suicide vests, guns and rockets were deployed to target the president, and three of those militants died in the attack, the spokesman Zabiullah Mujaheed said.
The Taliban has become a potent force again, CBS News correspondent Allen Pizzey reports. Neither the United States nor its allies have been able to stem the movement's growth in remote areas.
A police official who requested anonymity because he was not authorized to speak to media, said security forces killed three gunmen who had opened fire from an apartment block not far from the ceremony. He said they confiscated assault rifles and machine guns. Government officials could not immediately confirm that information.
The attack on Karzai began as dignitaries stood for the national anthem in stands opposite Kabul's main mosque. Hundreds of people fled in chaos as shots rang out. An Associated Press reporter at the scene said firing appeared to come from ruined houses a few hundred yards from where the VIPs were seated. A live TV broadcast of the ceremony was quickly cut.
Karzai was hustled away, surrounded by bodyguards, and left in one of four black SUVs. Foreign dignitaries and Cabinet ministers were also safe, Afghan and Western officials said.
The presidency said Nasir Ahmad Latefi, a local Shiite leader, and a 10-year boy died in the attack, and nine others including two lawmakers were wounded. One of the lawmakers, Fazel Rahman Samkanai, later died at a hospital, said Defense Ministry spokesman Gen. Mohammad Zahir Azimi.
The attack came despite unprecedented tight security for Sunday's celebrations.
For days Kabul was ringed by checkpoints with security forces and plainclothes intelligence officials searching vehicles. The area where the ceremonies took place had been blocked by troops, tanks and armored personnel carriers, and was closed to the general public.
The live TV coverage of the assassination attempt will add to the sense of insecurity in the Afghan capital, which has been spared the worst of the violence as fighting has escalated between Taliban insurgents and NATO and U.S.-led forces - leaving thousands dead last year.
It was the first militant attack in the city since mid-March.
In footage shown live on Afghan TV, two lawmakers who were sitting about 100 feet from Karzai were seen to be hit by the gunfire. One of the men slumped back in his seat, while the other lay on the ground.
People at the ceremony ducked for cover then fled - among them Afghan police and soldiers who were assembled for the event - but other security forces returned fire.
Taliban spokesman Mujaheed said the insurgents had managed to penetrate the security cordon and reach the national stadium near the parade area where the event was held.
He said BM-12 missiles - a crude rocket launched from a small platform - were used in the attack. He spoke to an AP reporter by phone from an undisclosed location.
Mohammad Saleh Saljoqi, a lawmaker at the ceremony, said there was continuous AK-47 fire, and one rocket - he described it as a rocket-propelled grenade - hit inside the Eid Gah mosque opposite where Karzai was sitting. The second hit when the president had already left, 164 feet away.
Authorities had rounded up for questioning about 100 people from the area where the gunfire originated, an Afghan intelligence official said on condition of anonymity because of agency policy.
Karzai, who has led Afghanistan since soon after a U.S.-led invasion ousted the Taliban regime in 2001, has escaped several assassination attempts.
His narrowest escape since he became president came in September 2002 when a gunman opened fire at close quarters as he visited the southern city of Kandahar. Three people, including the gunman, died in that attack.