All the Chinese diplomats and staff at the consulate were safe and were not harmed during the assault or the shootout, said senior police official Ameer Ahmad Sheikh.
The Baluch Liberation Army, a separatist group based in the southwestern province of Baluchistan, claimed responsibility for the attack and released photos of the three attackers. Karachi, the capital of neighboring Sindh province, has a militant presence, including Baluch separatists.
The attackers stormed the consulate shortly after 9 a.m., during business hours. They first opened fire at consulate guards and then managed to breach the main gate and enter the building, said Mohammad Ashfaq, a local police chief.
Pakistani security forces quickly surrounded the area. Local TV broadcast images showing smoke rising from the building, which also serves as the residence of Chinese diplomats and other staff.
Multiple blasts were heard soon afterward but Sheikh could not say what they were. After the shootout, which lasted for about an hour, the situation as brought under control.
"Because of a quick response of the guards and police, the terrorists could not" reach the Chinese diplomats, Sheikh said after the fighting ended. "We have completed the operation, and a search is still underway to trace and capture all suspects."
Sheikh said one of the attackers was wearing a suicide vest. Authorities will try and identify the assailants through fingerprints.
Dr Seemi Jamali, a spokeswoman at the Jinnah Hospital, said the bodies of two police officers were brought to the hospital morgue while one of the consulate guards who was wounded, is under treatment.
China is a longtime ally and has invested heavily in transport projects in Pakistan. The two countries have strengthened ties in recent years and China is currently building a network of roads and power plants under a project known as the China-Pakistan Economic Corridor, or CPEC.
No group has so far claimed responsibility for the attack in the Clifton area of the city. According to local TV reports, at least two policemen have been killed in the incident.
According to local media reports, citing local eyewitnesses and police, a blast and several shots were heard near the Chinese diplomatic mission in the Pakistani city of Karachi.
From three to four men tried to enter the consulate and opened fire on the guard standing outside the building. The security guards, however, have managed to foil the attack, Dunyanews reported.
As seen in footages on social media, a thick plume of smoke has been emerging from the mission's premises following a loud blast.
Local TV reported, citing police, that two policemen have been killed in the attack, while unconfirmed reports suggest that there are wounded.
Police have reportedly cordoned off the area. "Police and Rangers have reached the site," senior police official Pir Muhammad Shah told AFP.
Authorities have yet to comment on the situation, while it hasn't been immediately clear if the consulate was the target of an attack.
According to a local journalist, several Consulates are located near the Chinese consulate in Karachi, including the Kuwaiti and Russian diplomatic mission.