Armed men stormed a police station in the southern Pakistani city of Karachi on Friday, killing two people in a hail of gunfire and a series of loud explosions before they themselves were killed.
Security forces retook the building after several hours and killed three militants, a government spokesman said.
Police commandoes and a bomb disposal squad entered the building and a security sweep was under way.
Two people had been killed and 11 wounded in the militants' attack, a government spokesman said.
A huge explosion was heard inside the station after a series of blasts when it was first attacked.
The Pakistani Taliban, or Tehreek-e-Taliban Pakistan (TTP), took responsibility for the attack in a message sent by their spokesman to journalists.
The station houses offices of the city's most senior police. Deputy Inspector General Irfan Baloch told Reuters there could have been up to 30 policemen at the station at the time of the attack.
The TTP, separate from the Taliban ruling neighbouring Afghanistan, has recently increased attacks on police in the northwest of Pakistan as part of its campaign against the government in Islamabad.
Overseas cricket players are competing in the Pakistan Super League, and Karachi is one of the host cities.
There is a game scheduled for Saturday. The police station is located along the route to the stadium and the players' hotel is a few kilometres away.
Police sealed off traffic on the main thoroughfare through Karachi and heavy contingents of security forces, including paramilitary soldiers, had arrived at the scene.


Wave of bomb threats afflict European flights for third time this week
At least two children killed in bus crash in eastern France, authorities say
Vance repudiates Iran war after US electoral defeat
Malaysia ex-PM Najib Razak set for house arrest after party pays fine to leave jail
90 million displaced people at risk from climate threats, UN refugee agency says
