Taliban fighters armed with mortars and grenades have attacked a prison in northwest Pakistan, escaping with about 250 prisoners after a gunfight with security forces, officials have said.

At least 12 people, including six police. were killed and eight others wounded in the assault, staged by fighters disguised in police uniforms, officials said.

The attack in the town of Dera Ismail Khan began late on Monday with a huge explosion, intelligence officials said, speaking on condition of anonymity because they were not authorised to talk to reporters.

The fighters then detonated a series of smaller bombs to destroy the prison's boundary wall.

Security forces engaged the attackers, who were chanting "God is great" and "Long live the Taliban".

"Police and other law enforcing agencies are busy in clearing the jail," a senior government official Mushtaq Jadoon said, adding authorities have imposed a curfew in the city and asked residents to stay at home.

Pakistan's military confirmed that it had deployed forces to respond to the raid.

Al Jazeera's Imtiaz Tyab, reporting from the capital, Islamabad, said: "I would describe it [the attack] as extremely calculated."

Some of the Taliban fighters were using loudspeakers and calling the individual names of inmates to come out of the badly damaged prison, he said.

Officials have said that 40 to 45 so-called high-profile or high-value prisoners were freed, our correspondent added.

Taliban claim responsibility

Provincial prisons chief Khalid Abbas said the attackers escaped after a three-hour long gunfight with security forces.

"Security forces have entered the prison and cleared the building after which we have started counting prisoners with flashlights as there is no power in the prison and it is making our job difficult," Abbas told AFP news agency.

The Tehreek-e-Taliban Pakistan (TTP) claimed responsibility for the attack, according to a spokesperson. The group said that "over 100 fighters" had attacked the prison.

The Taliban have been waging a deadly uprising against the government for years that has killed thousands of security personnel and civilians.

Dera Ismail Khan, the capital of Khyber Pakhtunkhwa, is located on the edge of Pakistan's semi-autonomous tribal area, the main sanctuary for Taliban and al-Qaeda fighters.

The jail, which housed about 5,000 prisoners, is near the bordering town of Tank and adjacent to volatile South Waziristan Agency, the main area of influence of the outlawed TTP.

In April 2012, Taliban fighters armed with automatic weapons and rocket-propelled grenades battled their way into a prison in the city of Bannu in northwest Pakistan, freeing close to 400 prisoners, including at least 20 described by police as "very dangerous" fighters.

Source: Al Jazeera and agencies