Separatist militants killed four people during an unsuccessful attempt to storm a Chinese consulate, in an attack on Beijing's heavy investment in the country.

Two policemen and a father and son applying for travel documents died as three suicide attackers assaulted the mission in the port city of Karachi.

A militant group from the impoverished province of Baluchistan said it was responsible, claiming it was fighting Chinese “occupation” and exploitation of resources.

Imran Khan, prime minster, blamed the attack on "part of conspiracy" against China's close cooperation with Islamabad, which will see Pakistan become a key part of Beijing's plan to build a 21st century Silk Road through Asia.

The assault was claimed by the separatist Baloch Liberation Army (BLA) that opposes the projects linked to China's so-called Belt and Road initiative in resource-rich Baluchistan.

View photos Paramilitary forces and police take cover behind a wall during an attack on the Chinese embassy, where blasts and shots are heard, in Karachi More

Separatists have for decades campaigned against what they see as the unfair exploitation of resources, in particular natural gas and minerals.

China has poured huge sums into Pakistan and investment includes a deep-water port at Gwadar in south Baluchistan which will give Beijing access to the Arabian Sea, and a road and rail network throughout the country.

Pakistan has long blamed India for supporting Baloch insurgents, but Delhi denounced Friday's attack.

The militants attacked with grenades and firearms trying to enter the consulate building, but failed to get inside and were killed in an hour long shoot out with police. Chinese staff inside were unharmed.

China asked Pakistan to beef up security at the mission after the attack, but said it would not waver in its investment in the country.

View photos Paramilitary forces and police are seen during an attack on the Chinese embassy, where blasts and shots are heard, in Karachi Credit: Reuters More

Pakistan's Foreign Minister Shah Mahmood Qureshi spoke to his Chinese counterpart Wang Yi by phone and assured him that a "thorough investigation will be carried out to apprehend the perpetrators their financiers, planners and facilitators" linked to the attack.

A suicide bomber wounded five Chinese workers in August, by ramming into a bus ferrying them to the Saindak mining project in southwestern Baluchistan.

Karachi: Fidayeen of BLA attacked Chinese embassy in Karachi. pic.twitter.com/IRgrU28WzG — BLA Official (@BLA_Tweets) November 23, 2018

Meanwhile a bombing in a food market in the Orakzai area of Khyber Pukhtunkhwa province killed 35 people and wounded dozens more.

There was no immediate claim of responsibility for the attack in the town of Klaya. Most of the dead were minority Shia Muslims.

Across the border in Afghanistan a suicide blast in a mosque on an army base during Friday prayers killed at least 26 people.