Four gunmen attacked the Pakistani Stock Exchange building in the city of Karachi on Monday but security forces killed them all, police said.
Two other people were also killed, the military said, adding that security forces were conducting a sweep for any remaining attackers.
The gunmen attacked the building, which is in a high security zone that also houses the head offices of many private banks, with grenades and guns, said Ghulam Nabi Memon, chief of police in Pakistan's biggest city and its financial hub.
"Four attackers have been killed, they had come in a silver Corolla car," Memon told Reuters.
There was no immediate claim of responsibility.
The gunmen initially threw a grenade at security men posted outside the stock exchange compound then opened fire on a security post. The four were killed when security forces posted there responded.
Pakistan has long been plagued by Islamist militant violence but attacks have become less frequent in recent years after military operations against various factions in strongholds along the Afghan border.
The Pakistan Stock Exchange did not suspend trading during the attack, its managing director, Furrukh Khan, said.
A Counter-Terrorism Department official told Reuters the attackers were carrying significant quantities of ammunition and grenades in backpacks.
Apart from Islamist militants, Pakistan has also had to contend with separatist insurgents in Balochistan and Sindh provinces.
Separatists were responsible for an attack on the Chinese consulate in Karachi in 2018.
This month, three explosions on the same day claimed by a little-known separatist group killed four people including two soldiers in the southern province of Sindh, of which Karachi is capital.