Afghan security forces exchanged fire with gunmen barricaded in a house near the Pakistan consulate in the eastern city of Jalalabad on Wednesday after a suicide bomber blew himself up, officials said.
At least six people were killed and 11 wounded in the suicide attack and subsequent fighting, they said.
The attack on the consulate, which comes amid efforts to restart the stalled peace process with the Taliban and ease diplomatic tensions between India and Pakistan, resembled an attack on the Indian consulate in the northern city of Mazar-i-Sharif last week.
Witnesses in Jalalabad, the main trade gateway to the Khyber Pass and Pakistan, said heavy gunfire and a series of explosions could be heard and residents and children from a nearby school had been 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.
Two policemen were killed in the blast, the interior ministry said in a statement. Two other attackers took refuge in an empty government guest house nearby, it said.
The area had been sealed off and security forces were engaged in "eliminating" the attackers, it said.
There was no claim of responsibility.
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 fueled suspicion in India about militants sponsored from Pakistan and it cast a shadow over the latest effort to improve relations.
Tension between India and Pakistan has risen since the attack on its consulate and on an Indian air base that killed seven Indian military personnel near their border. India has blamed the attacks on Pakistan-based militants.
A rare meeting between the foreign secretaries of both countries had been tentatively scheduled for later this week, but it is unclear if it would still happen after the attacks.
Delegates from Afghanistan, Pakistan, China and the United States also met this week to try to resurrect efforts to end nearly 15 years of bloodshed in Afghanistan, even as fighting with the Taliban intensifies.
Pakistan says many Pakistani Taliban militants, who are separate from but allied with the Afghan Taliban, and are fighting to bring down the Pakistani state, have sought refuge in Afghanistan from a Pakistani army offensive.
In Pakistan on Wednesday, at least 14 people were killed in a blast near a polio vaccination center in the southwestern city of Quetta..