Militants firing automatic weapons and rockets attacked the Afghan president at a ceremony in Kabul on Sunday, missing their target but killing three other people and wounding eight. The Taliban claimed responsibility for the assault that sent President Hamid Karzai and foreign ambassadors scurrying for cover, underscoring the fragile grip of his US-backed government. Gunmen opened fire as a 21-gun salute echoed over the capital at an anniversary event to mark the mujahedeen victory over the Soviet occupation of Afghanistan. Hundreds of people, including army and police that had formed an honor guard inspected by Karzai minutes earlier, fled in chaos as shots rang out. The president was hustled away, surrounded by bodyguards, and left in a convoy of four black SUVs. The gunfire apparently came from a three-story guesthouse, popular with migrant laborers, about 300 meters from the stands where Karzai was seated alongside Cabinet ministers and senior diplomats who all escaped injury. A US Embassy official confirmed US Ambassador William Wood was also unharmed. A lawmaker, who was about 30 meters from the president, was among the dead. Residents reported that a 30-minute gunbattle then broke out between security forces and gunmen holed up in the guesthouse, located in a neighborhood of ruined mud brick buildings. Defense Minister Gen. Abdul Rahim Wardak said three attackers were killed by security forces, and assault rifles and machine guns were confiscated. He said three Afghan army soldiers were among the wounded. Taliban spokesman Zabiullah Mujaheed said six militants were deployed to target the president, and three of those militants died in the attack. He said they were armed with guns, rockets and suicide vests, although no suicide bombing was reported. The initial moments of the attack, which came as a marching band played the finale of the national anthem, were broadcast live until TV transmissions were cut. Hundreds of dignitaries could be seen diving for cover. Two lawmakers were hit by the gunfire. One of the men slumped back in his seat, while the other lay on the ground. Less than two hours later, Karzai appeared on state-run TV and said "everything is OK." Appearing calm, Karzai said "the enemy of Afghanistan" tried to disrupt the ceremony but was thwarted by security forces. He said several suspects were arrested. He smiled as he signed off his brief recorded statement. About 100 people were rounded up for questioning, an Afghan intelligence official said on condition of anonymity because he was not authorized to speak to media. Associated Press reporters saw a half-dozen people, who appeared to be migrant laborers from northern Afghanistan, sitting in the back of a police van outside the guesthouse, which was pocked with bullet holes. Windows had been smashed, and police barred the reporters from entering inside. The militant attack, the first in the capital since mid-March, came despite unprecedented tight security for Sunday's celebrations. In January, three Taliban suicide attackers hit Kabul's upscale Serena Hotel, killing eight people, including an American. 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 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 US-led forces. The fighting left about 8,000 dead last year, mostly militants in the south and east of the country, where Karzai's government has only a tenuous grip and little public support. NATO Secretary General Jaap de Hoop Scheffer joined several foreign leaders, including from neighboring Pakistan, in condemning Sunday's attack. "The Taliban has demonstrated once again that they will use the most extreme violence to oppose Afghanistan's freedom and democratic development," de Hoop Scheffer said in a statement. The presidency said Nasir Ahmad Latefi, a local Shiite leader, and a 10-year boy died in the attack. Lawmaker Fazel Rahman Samkanai died of his injuries at a hospital, Defense Ministry spokesman Gen. Mohammad Zahir Azimi said. 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, about 50 meters away.