PESHAWAR -  Two gunmen on a motorcycle shot dead an intelligence police officer in northwest Pakistan Monday, police said, in an attack claimed by the Pakistani Taliban and Islamic State group.

Akbar Ali, an intelligence sub-inspector, was on his way to work and waiting at a bus stop near his home in Charsadda district when the gunmen opened fire, Suhail Khalid, district police chief, told AFP.

"Akbar Ali was hit by four bullets from the front and was killed on the spot," he said, adding that the attackers used a 9mm pistol and fled the scene.

The attack was later claimed by the Islamic State group in a short statement posted on Amaq, its affiliated news agency.

"Islamic State fighters have killed a Pakistan intelligence agent in the Sardaryab region... of Pakistan," it said, referring to the local area. The Pakistani Taliban also claimed responsibility for the killing, said its spokesman Muhammad Khurasani.

"We accept responsibility for killing the Special Branch sub inspector in Charsadda," he said in a statement.

A similar attack on Sept 18 saw three Pakistani military employees killed in an ambush in Peshawar for which both Islamic State and a Pakistani Taliban faction claimed responsibility.

Authorities last week arrested two men accused of spreading Islamic State propaganda in Peshawar, with police officials saying its members were still active in some parts of the provincial capital.

Pakistan's military last month admitted for the first time that the Islamic State group had a presence in the country but said it had detained hundreds of its militants and prevented them from carrying out major attacks.

The army's spokesman said its forces had foiled planned attacks by IS on embassies and Islamabad airport, but denied the group was behind an August attack on a hospital that killed 73, as it had claimed.

IS, which has struggled for traction in Pakistan in the face of competition from well-established groups, gained its first toehold in January 2015 when six Pakistani Taliban leaders switched their allegiance from Al-Qaeda.

An attack on a bus in Karachi in May 2015 that killed 46 people was the first major incident officially claimed by IS in Pakistan.

Pakistan has been battling an Islamist insurgency since shortly after it decided to ally with the US following its invasion of Afghanistan in 2001. Violence has declined in recent years following a series of military offensives in the northwest border areas as well as concerted efforts to block the militants' sources of funding. But the remnants of militant groups are still able to carry out periodic bloody attacks, particularly in the northwest.

Separately, gunmen on a motorcyle shot dead two coast guards and a civilian and wounded a shopkeeper in a remote southwest coastal town, local police station chief Chakar Baloch told AFP Monday.

The incident, also confirmed by provincial police chief Ahsan Mahboob, took place late Sunday in Pasni, around 650 kilometres (403 miles) southwest of Quetta, the provincial capital of Balochistan where separatists demanding greater autonomy have been waging an insurgency for years. A spokesman for the Baloch Liberation Army, Gend Baloch, later claimed responsibility for the attack in a phone call to AFP.