Three suicide bombers attacked the Chinese consulate in Pakistan's southern city of Karachi early on Friday, but were killed before entering the building, the city's police chief said.
At least two police officers were killed in the attack, which was claimed by the Baloch Liberation Army (BLA), an ethnic insurgent group that said it opposes Chinese exploitation of natural resources in the country's southwest. It also describes itself as the Balochistan Liberation Army.
All Chinese staff at the consulate are safe, Pakistani Foreign Minister Shah Mahmood Qureshi said.
Pakistani Prime Minister Imran Khan ordered an inquiry into the incident.
The attack was the most prominent attack in Pakistan against neighbor and ally China, which is pouring billions of dollars into the country as part of its vast Belt and Road initiative.
A blast and gunshots rang out early on Friday in the affluent Clifton neighborhood, where the consulate is located, and a plume of smoke rose over the area after the explosion.
Karachi Police Chief Amir Shaikh said the three attackers came in a car filled with explosives but failed to get inside the heavily fortified compound.
"They tried to get inside but the Rangers and police killed one of the terrorists," Shaikh said.
A gun battle broke out with the two other attackers, but they were also killed, he added.
"There were three attackers and all three have been killed," Shaikh said. "They could not even get in the compound. They tried to get into the visa section."
A spokesman for the BLA confirmed there were three suicide attackers.
"They stormed the Chinese embassy in Karachi. China is exploiting our resources," spokesman Jiand Baloch told Reuters by telephone.
The insurgents are based in the southwestern province of Baluchistan, where Chinese money has funded development of a deep-water port in the city of Gwadar.
Baluchistan has rich mineral and natural gas reserves but remains Pakistan's poorest province.
The BLA says the state is taking over lands belonging to the indigenous Baloch people and have targeted Chinese-funded projects.
In August, a BLA suicide bomber attacked a bus full of Chinese mining workers in Baluchistan, wounding five people.