KARACHI — A Taliban suicide bomber rammed a truck packed with explosives into a compound housing a paramilitary force in Pakistan’s largest city on Thursday, killing three officers and wounding 20.
The attack underlined the deteriorating security in Karachi, the sprawling port city of 18 million people that is the nation’s economic hub.
Violence has escalated in recent years in the city as armed groups fight for control of land and resources, and militant groups such as the Taliban have used the chaos to consolidate their foothold.
Thursday’s attack targeted a housing compound for the Rangers, a paramilitary force that is tasked with helping Karachi police maintain security in the city, said Javed Odho, deputy inspector general of the Karachi police.
Three security personnel were killed and 20 were wounded in the explosion, said a spokesman for the Rangers, speaking on condition of anonymity in line with regulations. He said the blast would not deter the force from pursuing operations against militants .
Witnesses reported seeing a large plume of smoke rise into the sky from the residential block.
Pakistani television showed images of the blast site, what appeared to be an apartment block with a gaping hole in the middle. A part of the two-story building was razed.
The Rangers set up a perimeter around the building to keep journalists and bystanders at bay.
One of the Rangers, Muhammed Farooq, said he was preparing for work when he looked out the window and saw a vehicle smash through the main gate and into the building.
‘‘Then there was a really big bang and I lost my balance and I saw a lot of smoke and then I lost consciousness,’’ he said, speaking from the hospital.
Taliban spokesman Ahsanullah Ahsan said the group claimed responsibility for the attack.
‘‘We punished the Rangers as they are working against us and they are doing nothing to serve Islam,’’ Ahsan said over the telephone from an undisclosed location.
Taliban militants are known to operate inside the city and have targeted security officials and buildings in the past.
Half a dozen Taliban militants attacked a major naval base in Karachi in May 2011, killing at least 10 people and destroying two US-supplied surveillance aircraft.
‘We punished the Rangers as they are working against us and they are doing nothing to serve Islam.’
In September 2011, a Taliban suicide bomber detonated a vehicle packed with explosives outside the home of a senior police officer tasked with cracking down on militants in Karachi. At least eight people died, although the officer survived.
Karachi is the capital of Sindh Province in southern Pakistan. It lies on the Arabian Sea and is the country’s wealthiest city, though beset by escalating violence.
Armed groups backed by political parties are believed to be behind much of the city’s violence, such as targeted killings, kidnappings and extortion.
The chaos has allowed militants such as the Taliban, who have long had a presence in the city, to strengthen their footprint there.
The Pakistani Supreme Court last week held hearings examining the violence, which some worry threatens Karachi’s stability.