By Agence France-Presse
Up to four gunmen tried to enter the consulate but were intercepted by security guards at a checkpoint, senior local police official Javaid Alam Odho told AFP.
An exchange of fire resulted "killing two of our constables and critically wounding another", he said.
He added that the group "ran away" but did not confirm if the attack was over, saying the area had been cordoned off and security forces were conducting a clearing operation.
Police and Rangers were on the scene, police said. Pictures posted to social media purportedly of the attack showed smoke rising from the area.
The attack was claimed by a separatist militant group from Pakistan's southwestern province of Balochistan, which is at the centre of a major Chinese investment project in the country.
"We have carried out this attack and our action is continuing," the spokesman for the Balochistan Liberation Army (BLA), Geand Baloch, told AFP by telephone from an undisclosed location.
The BLA is just one of the militant groups operating in Balochistan, Pakistan's largest and poorest province, which is rife with ethnic, sectarian and separatist insurgencies.
China, one of Pakistan's closest allies, has poured billions into the South Asian country in recent years as part of a massive infrastructure project that seeks to connect its western province Xinjiang with the Arabian Sea port of Gwadar.
The project, the China-Pakistan Economic Corridor, is one of the largest projects in Beijing's "One Belt One Road" initiative, comprising a network of roads and sea routes involving 65 countries.
But for Pakistan, participating in the project presents an enormous challenge in a country plagued by weak institutions, endemic corruption and a range of insurgencies in areas slated to host the corridor.
The subject of economic dividends from CPEC is extremely sensitive in some of the areas the corridor will run through -- particularly in resource-rich Balochistan.
Since the beginning of the project militants have repeatedly attacked construction sites and targeted Chinese workers.
Karachi, Pakistan's largest city and a financial hub, was for years rife with political, sectarian and ethnic militancy.
A crackdown in the city by security forces in recent years has brought a lull in violence, but scattered attacks still take place.