PESHAWAR - Dozens of heavily armed Taliban fighters freed nearly 250 prisoners, including hardcore militants, during a sophisticated overnight attack on a jail that killed 13 people, officials said Tuesday.

Armed with guns, mortars, rocket-propelled grenades and bombs, the Taliban bombarded the prison in Dera Ismail Khan before escaping with scores of inmates after a three-hour shootout.

The attack by well-trained gunmen, disguised in police uniforms, will heighten concerns about the ability of the Taliban to operate with impunity in parts of the nuclear-armed state. They appeared easily to overpower police on duty at the prison.

At least 248 prisoners escaped, of whom six were later rearrested, senior government official Mushtaq Jadoon told a private TV channel, describing about 30 of them as ‘hardcore militants’. Officials blamed a combination of negligence and lack of communication among many security agencies, but some suggested there may have been a degree of insider help.

Just hours before the attack, army and police units had met at the jail to discuss security, one source said on condition of anonymity due to the sensitivity of the matter.

"It is very difficult to attack such a place without proper information or contacts," said the police source, adding that some prisoners were suspected to have been in touch with the Taliban by mobile phones provided by sympathetic wardens. "They are corrupt, lazy and unprofessional. And the militants may have supporters in the city."

Another senior official in Peshawar said only about 70 of the 200 prison guards who were meant to be on duty were present that night. "Most policemen ran for their lives once the attack started, leaving their weapons behind," the official told Reuters. "They could have easily killed some of the attackers but they even gave up their own guns, providing the attackers with more ammo."

Malik Qasim, prisons adviser to the KPK chief minister, confirmed that 248 had escaped. He said five female inmates were taken away with one female constable.

The Central Prison in Dera Ismail Khan can hold up to 5,000 inmates and around 300 were being held in connection with attacks on security forces and sectarian killings.

But it was not clear how many were present during the assault, which began late Monday and ended early Tuesday.

Khyber Pakhtunkhwa Chief Minister Pervez Khattak, a member of cricket star Imran Khan's party that advocates peace talks with the Taliban, branded the latest attack a failure of intelligence agencies.

The Taliban, which has led a domestic insurgency since 2007 killing thousands of people, claimed responsibility.

"Some 150 Taliban, including 60 suicide bombers, attacked the Central Prison and managed to free about 300 prisoners," Taliban spokesman Shahidullah Shahid told AFP by telephone.

A security official in the city told AFP the militants arrived in more than a dozen vehicles and that two Taliban commanders were among those who escaped.

"Militants also torched jail records and an office," he said on condition of anonymity as he was not allowed to talk to the media.

Jadoon said the fighters planted dozens of explosive devices in the jail which were later defused by bomb disposal experts. A curfew was imposed in the city after the attack.

"We appeal on people to stay at home. It is to avoid any damage if army, police and paramilitary take any action," Jadoon said.

The siege began with rocket fire, killing two policemen and providing cover for 50-60 militants to storm inside, Jadoon said.

"First they destroyed a police armoured vehicle parked at the front gate," he said.

"Police killed one militant who was trying to flee and who opened fire on police near the jail," he added.

Provincial prisons chief Khalid Abbas said the gunfight raged for three hours. Militants wearing police uniforms stormed the prison after bombing its outer wall and throwing hand grenades at guards.

The prison was plunged into darkness by an electricity outage and after the battle, security forces searched the jail to count inmates by flashlight to determine how many had escaped, he said.

"At least 13 people have been killed and eight injured," Abbas told AFP.

Among the dead were six police officers, one civilian, two attackers and four prisoners, he said. Two jail officials told AFP that three of the four prisoners were members of the Shia minority.

Government and intelligence officials said they had warned that the prison would be targeted, but Abbas defended his prison guards, saying they were not trained to respond to such an attack.