At least two people have been left dead after the Taliban launched a complex attack on the Afghan parliament.
A suicide car bomber struck at the entrance and gunmen battled police as politicians were meeting inside to confirm the appointment of a defence minister, police and witnesses said.
Afghan security forces managed to repel the attack, killing all seven gunmen and ensuring that no members of parliament were harmed.
But the audacious assault came as the Taliban captured two districts in as many days in the country's north, displaying their ability to operate on multiple fronts.
Interior Ministry spokesman Sediq Sediqqi said the attack began with a car bomb explosion near the entrance to parliament. Gunmen then attempted to storm the compound but were pushed back by security forces and eventually corralled into a nearby building that was under construction.
Mr Sediqqi later said all seven attackers were killed by police and that no members of parliament were harmed. "It is over now," he said.
Mr Sediqqi said a woman the a 10-year-old girl were killed, and Health Ministry spokesman Mohammad Ismail Kahousi said 31 civilians were wounded in the parliament attack, including two women and two children.
Sidiqa Mubarez, a member of parliament, said the building was rocked by the large explosion and that some people were wounded by flying glass.
She said the explosion happened shortly after Masoom Stanekzai had arrived to be confirmed as defence minister, a post that has been vacant for nine months. The vote was delayed by the attack.
The Taliban claimed the attack in a statement to media.
Afghan President Ashraf Ghani strongly condemned the assault.
"Targeting innocent people in the holy month of Ramadan is a clear act of hostility against the religion of Islam," his office said in a statement, adding that the perpetrators "are criminals who are bound by no creed or religion".
The attack on parliament came hours after the Taliban seized a second district in the northern Kunduz province, which has borne the brunt of their annual warm-weather offensive.
Mohammad Yusuf Ayubi, head of the provincial council, said the insurgents attacked the district of Dashti Archi from four sides and took full control of the area early on Monday. He said local forces suffered casualties but did not have a precise count.
He said around 150,000 residents of the district were trapped by the fighting.
The Taliban confirmed that they had captured the district, as well as ammunition and four tanks, in an emailed statement.
The Taliban seized control of the Chardara district in Kunduz on Sunday. The insurgents attacked the provincial capital, also called Kunduz, in a surprise attack in April and nearly captured it before Afghan forces pushed them back.