Three attackers were also killed in the assault on the consulate in the city’s high-security red zone, according to a Pakistan foreign ministry spokesman.
The Baloch Liberation Army, a separatist group, claimed responsibility for the attack in a tweet that included a photo of three unidentified men and the message: “Karachi: Fidayeen of BLA attacked the Chinese embassy in Karachi.”
“Fidayeen” is an Arabic term that loosely translates as “one who sacrifices himself.”
In a statement released after the attack, the group said its objectives were “clear — we will not tolerate any Chinese military expansionist endeavors on Baloch soil.”
CNN does not have independent confirmation of the group’s involvement.
Security was immediately ramped up at consulates all over Karachi, Sindh Governor Imran Ismael told CNN.
Two of the four victims were uniformed police officers, according to Seemi Jamali, the head of Emergency at Jinnah Hospital. No Chinese nationals were among the dead, the hospital said.
Pakistan’s Prime Minister Imran Khan condemned the attack, ordering a “complete inquiry.”
In a statement, Khan called it “part of conspiracy against Pakistan and China’s economic and strategic cooperation.
“However, such incidents will never be able to undermine the Pakistan-China relationship that is mightier than Himalaya and deeper than Arabian sea.”
In a statement, Chinese Foreign Ministry spokesman Geng Shuang said that all Chinese consulate staff “are safe.”
“China strongly condemns any terrorist attacks targeting diplomats and send its condolences to the deceased guards and their families,” he said.
Ahsan Jamil, an equity portfolio manager at an investment firm whose office faces the Chinese consulate, told CNN that the shots started around 9:15 (11:15 p.m. ET Thursday night) and lasted around 30 to 45 minutes.
He said the area is surrounded by schools, and that parents were being turned away by school staff because of the gunfire and explosions, but otherwise there were “no other signs of panic.” He said he saw police cars driving toward the area.
When journalist Amir Latif, from Turkey’s Anadolu News Agency, spoke to CNN he could still hear gunshots.
“(The consulate is in) a very heavily guarded area, the firing is still continuing and we can hear small blasts, which suggests the attackers are still engaged with security forces,” Latif said.
“The firing is still continuing and the police have not made any official statement but eyewitnesses said there are three to four attackers, heavily armed attackers who tried to storm the Chinese consulate and still we can hear gunshots,” Latif said.
It’s unclear whether the terrorists were inside the compound or near the consulate.
Pakistani Foreign Minister Shah Mehmood Qureshi later confirmed that the operation to secure the Chinese compound was over.
“Our Chinese friends and officials — around 21 people — are all safe,” he told a media briefing.
“The area is clear. Those who want to prevent peace in this country were brilliantly stalled by the young security officers of this country.
“Pakistan and China’s friendship cannot be disturbed. Pakistan and China have joint security attempts to prevent such attempts at destroying the work that the two countries are working on.”
He added that he hoped to speak to his Chinese counterpart “soon.”‘
The Balochistan Liberation Army (BLA) has conducted a low-level separatist insurgency against the state for nearly two decades.
The organization, which grew out of anger over the state’s perceived monopoly over the province’s mineral resources, previously have killed and kidnapped Chinese engineers working in the province.
Balochistan, the country’s largest but least populated province, is at the core of the massive multibillion-dollar cooperation deal known as China-Pakistan Economic Corridor (CPEC).
Pakistan’s efforts to quash the insurgency in the oil and gas-rich region have intensified as Beijing is developing the area’s key CPEC port, Gwadar.
After a BLA attack on a bus carrying Chinese engineers in August, one of the militant group’s leaders warned that if Beijing continues “exploiting” the resources of Balochistan, it should be prepared for more attacks.
The group has killed dozens of Pakistanis working on CPEC projects in Balochistan.
Human rights groups accuse the security officials of crushing dissent and security officials of extrajudicial killings and enforced disappearances.
The military denies the claims, saying that the BLA has killed Pakistani laborers in cold blood and conducted terrorist operations to destabilize the state.
Earlier this week Dawn reported that 265 Baloch militants, including BLA members, had given up their weapons as part of a government amnesty.
CNN’s Bard Wilkinson contributed to this report.