KARACHI, Pakistan — A top Karachi police commander known for harsh tactics has been forced out after what he called a shootout with the Taliban ended in the death of an aspiring model popular on social media, triggering days of protests.

The commander, former Senior Superintendent Rao Anwar, had long been prominent in the fight against militancy in the northern neighborhoods of Karachi he oversaw. Those areas were once notorious for being practically run by the Pakistani Taliban and other militant groups, who inflicted heavy tolls on the security forces until 2015.

Campaigns by the superintendent’s forces, along with paramilitary groups like the Sindh Rangers, began turning the balance of power around. But the effort was haunted by accusations of extrajudicial killings, as it began looking as much like an indiscriminate crackdown on ethnic Pashtun communities as a targeted campaign against the militants who sheltered among them. The commander’s methods, in particular, began coming under intense criticism.

An episode this month may end up being the final straw. On Jan. 13, Superintendent Anwar released a statement claiming that he and his officers had thwarted a deadly attack on Karachi’s airport, killing four unidentified militants who he said had a history of killing “police, Rangers and army personnel.”