At least seven people including four attackers died after gunmen attacked Karachi's stock exchange building on Monday morning.
Police said four men stormed the building in Pakistan's financial centre and were killed after paramilitary rangers responded.
Two guards and a policeman were killed in the attack, which was later claimed by the Balochistan Liberation Army, a separatist militant group from a neighbouring province.
The militants launched a grenade attack at the main gate before running into the building and firing indiscriminately.
The building is in a high-security zone and also houses the head offices of many private banks.
Employees sheltered inside as the shooting raged for nearly an hour.
Rizwan Ahmed, a police official at the scene, told the Associated Press that food supplies were found on the bodies of the gunmen, indicating they may have planned a long siege.
Pakistani politicians praised the security forces and guards at the building who appeared to have prevented what could have been a far more deadly incident.
The Balochistan Liberation Army released a photograph of the four militants from its Majeed suicide brigade.
The men were pictured in fatigues and named as Tasleem Baloch, alias Muslim, Shehzad Baloch, alias Cobra, Salman Hammal, alias Notak and Siraj Kungur, alias Yaagi.
Karachi was for years notorious for violence after ethnic divides, terrorism and organised crime plunged the country's financial hub into near chaos.
Recent years have seen a dramatic improvement in security in the sprawling port city of more than 20 million, although Baloch separatist militants attacked the city's Chinese consulate in 2018.
Imran Ismail, governor of Sindh province which includes Karachi, condemned the attack, saying it was “aimed at tarnishing our relentless war on terror”.
He said he had ordered security agencies “to ensure that the perpetrators are caught alive and their handlers are accorded exemplary punishments. We shall protect Sindh at all costs.”
Unverified photographs and film footage posted on social media purporting to come from the attack showed dead or badly wounded people lying in pools of blood on the pavement outside and blood-spattered corridors inside a building.
Speaking to Geo TV, Karachi's inspector general said the situation was under control and all the attackers were dead.
He said the attackers were disguised as off-duty policemen and had arrived at the scene in two sedans.
Pakistan's security situation has improved greatly over recent years after 15 years of widespread bloodshed and insurgency from 2001 onwards.
But Baloch militants and the remnants of the Pakistani Taliban have continued to strike military and government targets, largely in Balochistan and Khyber Pakhtunkhwa provinces.
The Balochistan Liberation Army sent suicide attackers to the Chinese consulate in November 2018, and a hotel in the new port of Gwadar in May 2019.
The separatist movement, which is designated a terrorist group by the US and UK, says it is fighting for independence for Balochistan. The British government's designation described it as "comprised of tribal groups based in the Balochistan area of Eastern Pakistan, which aims to establish an independent nation encompassing the Baloch-dominated areas of Pakistan, Afghanistan and Iran".
Pakistan says it is a proxy funded by India and Afghanistan.