A branch of the Islamic State group (ISIS) claimed responsibility for an attack Wednesday on Pakistan's consulate in eastern Afghanistan that killed at least seven members of the Afghan security forces.

The attack in Jalalabad, the capital of the volatile Nangarhar province that borders Pakistan, started when a suicide bomber detonated his explosives vest outside the diplomatic mission, said Attaullah Khyogani, spokesman for the province's governor.

The explosion triggered a gunbattle between Afghan security forces and the militants. Along with the policemen killed, seven people were also wounded in the attack, Khyogani added.

He said all three attackers were killed, including the suicide bomber. The two gunmen, who later took positions in a guesthouse close to the consulate, were killed hours later, Khyogani said.

The U.S.-based SITE Intelligence Group, which monitors militant trafficking, said the affiliate known as the "Khorasan Province of the Islamic State" claimed three of its "soldiers" attacked the consulate.

Hazrat Hussein Mashraqiwal, the spokesman for the provincial police chief, said three police and two intelligence officers were among the dead and three civilians were among the wounded.

It was the first insurgent-style attack on a Pakistani diplomatic mission in Afghanistan, an official at the Pakistani embassy said, speaking on condition of anonymity as he was not authorized to speak to the media.

Pakistani government properties have come under attack in the past during protests by Afghans angry at Islamabad's perceived support for the Taliban, who have waged war on the Kabul administration for more than 14 years.

The scene of the attack is close to a hospital and schools as well as the Indian Consulate. The schools were evacuated, officials said.

AFGHANISTAN-BLAST/BATTLE

A school girl falls as she and others run after a blast in Jalalabad on Tuesday. Afghan security forces exchanged fire with gunmen barricaded in a house near the Pakistan consulate in the eastern city after a suicide bomber blew himself up, officials said. (Parwiz/Reuters)

The Pakistani consulate is usually busy during morning rush hour as people line up for visas. The suicide bomber joined the visa queue before blowing himself up, officials said. All consular staff were quickly evacuated from the building. 

In Islamabad, the foreign affairs ministry condemned what it called a terrorist attack on its consulate and requested a thorough investigation. One official at the consulate was slightly injured by broken glass, it said.

The office of Pakistan's Prime Minister Nawaz Sharif said Afghan President Ashraf Ghani telephoned him to guarantee enhanced security for Pakistani diplomats in Afghanistan.

Sharif's office said the two leaders agreed that "terrorism is a common enemy for both the countries and we will fight this menace together."

Nangarhar is home to a number of insurgent groups and criminal gangs who benefit from the proximity to the Pakistan border. The Islamic State group has established a presence in the province, having fought with Taliban gunmen in recent months to take control of at least four border districts.

Increasing violence

The attack came two days after Islamabad hosted a meeting of representatives of Afghanistan, Pakistan, China and the United States to discuss ending the Taliban's 14-year insurgency.

Pakistan is widely believed to support the Taliban through its security service, though Islamabad denies the claim. The Taliban have split in recent months, with insurgent factions divided over whether to join the peace process.

Wednesday's attack is the latest in a spate of violence this month, raising concerns of a tough year ahead for Afghanistan as the Taliban are expected to escalate their attacks, possibly in order to enter into peace negotiations from a position of strength.

In early January, a restaurant frequented by foreigners in Kabul and a contractor camp on the outskirts of the Afghan capital were attacked, and the Indian Consulate in the northern city of Mazar-i-Sharif was besieged for more than 24 hours.

Further south, in Helmand province, the governor of Gereshk district in the poppy-growing river valley, said Wednesday that nine police were killed overnight in a Taliban assault. Mohammad Ashraf said two others were wounded. He gave no further details.

Helmand has seen fierce fighting between the Taliban and government forces in recent months. A Taliban heartland, Helmand is the source of opium that produces most of the world's heroin and provides an important funding source for the insurgency.