The Islamic State (IS) group has claimed responsibility for a suicide attack targeting the Pakistani consulate in the eastern Afghan city of Jalalabad.
In an Arabic statement released via Twitter, the group said the attack was carried out by three IS fighters, two of whom blew themselves up by detonating explosive belts.
Afghan officials said all three attackers and at least seven members of the security forces died during the attack by the radical Islamist movement which has so far avoided striking high-profile Pakistani targets.
Witnesses said heavy gunfire and a series of explosions could be heard during a battle lasting several hours and residents and children from a nearby school were evacuated.
Attaullah Khogyani, a spokesman for the provincial governor, said a suicide bomber had tried to join a queue of people seeking visas to Pakistan and blew himself up after being prevented from entering the building.
Pakistan condemned the attack but said all members of the consulate staff were safe, with one official slightly injured by broken glass.
The attack came amid efforts to restart the stalled peace process with the Taliban and ease diplomatic tensions between India and Pakistan.
Last week, a group of attackers barricaded themselves in a house and resisted security forces for about 24 hours after a suicide attack on the Indian consulate in Mazar-i-Sharif.
The group responsible for that attack has not been identified but the incident fuelled suspicion in India about militants sponsored from Pakistan and it cast a shadow over the latest effort to improve relations.