The attack came as the Afghan president's nominee for the crucial post of defence minister was to be introduced in parliament and ended two hours later when all seven attackers, including a suicide car bomber, were dead.
The assault on such a high-profile target in downtown Kabul raises fresh questions about security as Afghan forces battle a resurgent Taliban for the first time without the aid of NATO forces, who ended their combat mission in December.
Two civilians, a woman and a child, were killed in the attack, according to police and the United Nations.
Deputy interior ministry spokesman Najib Danish said there were seven attackers and the health ministry reported 31 people, including five women and a child, wounded.
More From This Section
Dramatic television footage of the moment the first explosion struck showed pandemonium and screams inside parliament, with Speaker Abdul Rauf Ibrahimi sitting in his chair, calmly telling lawmakers "it's an electrical issue".
"In a few seconds the hall was filled with smoke and MPs began fleeing the building," he told AFP.
The Taliban launched a countrywide offensive in late April, stepping up attacks on government and foreign targets in what is expected to be the bloodiest fighting season in a decade.
The militants recently rebuffed requests from senior Afghan clerics to halt attacks during the fasting month of Ramadan even as a surge in violence has sent civilian casualties soaring.
The Taliban, toppled from power in the 2001 US invasion of Afghanistan, swiftly claimed responsibility for the latest attack.