The assailants launched a grenade attack at the main gate to the building and opened fire but police say they failed to make it to the trading floor.
Staff inside took refuge in locked rooms and many were evacuated. Security forces are searching the area.
Militants from the Baloch Liberation Army say they were behind the attack.
Ethnic Baloch groups have fought a long-running insurgency for a separate homeland and a greater share of resources in Pakistan’s Balochistan province.
“We locked ourselves in our offices,” Asad Javed, who works at a brokerage in the stock exchange building, which is in a high security zone that also houses the head offices of several banks, told Reuters.
Javed said he was on the ground floor when he heard gunfire and an explosion and people scattered for safety.
The police chief in Pakistan’s biggest city and financial hub, Ghulam Nabi Memon, told Reuters the gunmen attacked with grenades and guns after pulling up in a silver Corolla car.
They threw a grenade at security men posted outside the compound then opened fire on a security post. The four were killed when security forces posted there responded.
Their car was abandoned where they left it.
Two guards and a policeman were killed and seven people were wounded, Deputy inspector general of police Sharjil Kharal told media.
A counter-terrorism official told Reuters the attackers were carrying significant quantities of ammunition and grenades in backpacks.
The BLA claimed responsibility in a brief message on a Twitter account set up shortly before the raid, describing it as a “self-sacrificing” attack carried out by its Majeed brigade.
The account was suspended a short time after the attack.
Separatists have been fighting for years in resource-rich Balochistan, complaining the southwestern province’s gas and mineral wealth is unfairly exploited by Pakistan’s richer, more powerful provinces.
The BLA’s Majeed brigade also took responsibility for an attack on the Chinese consulate in Karachi in 2018. Several projects linked to China’s Belt and Road initiative are in Balochistan.