“The Taliban have taken over areas, brought in their people and established strongholds,” Mr. Gayer said. “The question is how far they can go.”

In many ways, Karachi has become an adjunct of the conflict in the tribal belt. The city’s militant factions are organized according to conflict-hit northwestern districts like Waziristan, the Swat Valley and Mohmand. Their extortion rackets target ethnic Pashtun traders, and their guns have been trained on members of the Awami National Party, a secular Pashtun party that opposes the Taliban ideology.

The Taliban’s internecine disputes, often over the proceeds of crime, also spill onto the streets of Karachi, although in the past year, the Swat Taliban have become the dominant faction since their leader, Maulana Fazlullah, assumed overall control of the movement.

All of that has made the Taliban powerful players in the city’s already complicated mosaic of violent gangs linked to crime, politics and ethnic groups. Taliban attacks have killed 80 members of the Awami National Party, the party says, and largely driven it from the city. Polio transmission rates have shot up after militant attacks on vaccination teams. And the police have come under unprecedented attack.

In January, a militant suicide bomber killed Muhammad Aslam Khan, widely known as Chaudry Aslam, perhaps the city’s most famous police officer, who used to boast of his prowess in capturing and killing Taliban fighters. In the section of the city where the Taliban are most active, only five of 15 police stations are now considered safe, said Irfan Ali Baloch, a senior police commander.

The police station in one neighborhood, Mominabad, offers an example of the threat. Militants have bombed it three times in recent months, officers said. One policeman was killed and two others were wounded in an attack in June, as they waited to have their vehicle repaired. In July, a police inspector was shot dead as he traveled to work.