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.


Trump backs down on Greenland tariffs, says deal framework reached
Death toll in Karachi mall fire climbs to around 50, official says
Rescuers search for survivors after landslide at New Zealand campsite
Israeli fire kills 11 Palestinians, Gaza medics say
Trump says US will not use force to acquire Greenland
