An Afghan court became a battleground on Wednesday when five militants stormed the building where Taliban insurgents were standing trial.
Officials say at least seven people were killed and over 70 injured in the attack in the province of Farah, near the Iranian border.
One of the attackers blew himself up, while a gun battle ensued between Afghan security forces and other militants.
The Taliban claimed responsibility for the attack in a text message sent to the media, adding that the insurgents standing trial had been freed.
The incident adds to concerns over how Afghan security forces will managed once NATO-led combat troops withdraw at the end of next year.