A total of seven people have died and 19 others were injured following a terror attack on the Karachi Police Office (KPO), a spokesman of the Sindh province confirmed on Saturday.

Taking to Twitter, the spokesman Murtaza Wahab said the victims comprised two militants who were shot dead; another terrorist who blew himself up; three law enforcers; and one civilian, reports Xinhua news agency.

He said that one of the injured was in critical condition and the rest of the wounded were stable, adding that the attacked five-floor building and the entire surrounding area have been cleared.

The attack took place at around 7.10 p.m. on Friday evening when the attackers opened fire and hurled hand grenades at the police office near the Saddar area of Karachi, Deputy Inspector General of south zone Karachi Irfan Baloch told the media.

He said that terrorists entered the building from the main gate and used more than 25 grenades throughout their offensive.

Baloch said the main combat took place on the third and fourth floor of the building, and as the forces moved on to the fifth floor, they faced comparatively less resistance from the attackers.

"We rescued people from all floors of the building, who became hostage, including the official staff of the Additional Inspector General of Karachi police on the third floor," he said.

Muqaddas Haider, a senior police official of the Karachi police, told the media that all the attackers came in a single car, adding that one of them blew himself up on the fourth floor while the other two were shot dead on the roof.

As the terrorist blew himself up, a powerful explosion took place which shattered the window glass of nearby buildings, the police said.

Eyewitnesses told Xinhua that the lights of the building under attack had been turned off soon after the attack, while gunshots and multiple explosions were constantly heard during the three-hour-long attack.

The Tehrik-e-Taliban Pakistan terror group claimed responsibility for the attack.

In a statement issued on Friday night, it said the Karachi police office was the target of the attack.

Karachi South Deputy Inspector General of Police Irfan Baloch said up to 30 policemen were present at the time of the attack.

He added the terrorists carried hand grenades and Kalashnikovs, besides gram, dates, water bottles and other items.

The car in which the terrorists had come was left running throughout the operation.

The police later recovered an Ajrak, a mat, slippers, water bottles, a number plate placed on the dashboard and a magazine, The Express Tribune reported.

Prime Minister Shehbaz Sharif strongly condemned the terrorist attack, appreciating the police and security forces for their effective action against the terrorists.

"Terrorists once again targeted Karachi but this kind of cowardly act could not weaken the resolve of police and law enforcement agencies. The whole nation stood with police and security institutions... collective efforts needed to root out the menace of terrorism," he added.