At least two police officers and three gunmen have been killed in an attack on the Chinese consulate in the Pakistani port city of Karachi.

Separatist militants who oppose Chinese investment projects in western Pakistan say they carried out the attack.

The attack happened at the same time as a suicide attacker on a motorbike set off explosives in a crowded festival and market in northwest Pakistan, killing at least 25 people.

The attack on China's consulate in Karachi was claimed by the separatist Baloch Liberation Army (BLA) insurgent projects linked to its Belt and Road initiative in resource-rich Baluchistan.

Pakistani Prime Minister Imran Khan called it "part ofconspiracy" against Pakistani and Chinese economic and strategic cooperation and ordered an inquiry, his office said. 

Pakistan has long accused its old rival, India, of supporting the nationalist insurgents in Baluchistan, whileIndia accused Pakistan of nurturing Islamist militants throughout the region. 

India denies helping the Baluchistan insurgents and was quick to condemn the violence. 

"The perpetrators of this heinous attack should be brought to justice expeditiously," India's foreign ministry said in a statement. 

India has for decades accused Pakistan of supporting Islamists fighting Indian security forces in the Indian part of the Himalayan region of Kashmir, where increasing violence flared again on Friday with Indian forces killing six militants in a clash.

India and the United States also accuse Pakistan of supporting the Afghan Taliban. Pakistan denies that.