Updated

Prison guards said Tuesday that they were totally overwhelmed when around 150 heavily armed Taliban fighters staged a late-night attack on their jail in northwest Pakistan, freeing over 250 prisoners including over three dozen suspected militants.

It was the second such attack by the Taliban on a prison in the northwest within the last 18 months. But even so, the security forces were totally unprepared for the raid, despite senior prison officials having received intelligence indicating an attack was likely. Over a dozen people were killed in the assault.

The incident in the town of Dera Ismail Khan raises serious questions about state institutions' capacity to battle a domestic Taliban insurgency that has raged for years and killed tens of thousands of security personnel and civilians.

Hidayat Ullah, a policeman who was guarding the prison when the attack started at around 11:30 p.m. on Monday night, said he and several colleagues jumped into an armored vehicle inside the prison grounds and drove to the main gate to defend the compound. They directed fire at the gate after the militants blew it up, but a mortar or rocket-propelled grenade hit their vehicle, killing two policemen and wounding Ullah and two others.

"After that, I don't know what happened," said Ullah at a hospital where he was being treated.

More On This...

    Another prison official, Zeeshan Khan, said he was in the jail's main building when the attack started with two loud explosions. He rushed to the top of the building and saw a large group of militants on motorcycles, cars and a minibus rushing into the prison compound through the knocked-down walls. The militants also used dozens of smaller bombs to destroy other parts of the prison.

    "The jail guards on the top posts started firing to prevent them from getting closer, but to no avail, and the guards were the first victims of their massive firing," said Khan. "The jail security officials called for immediate reinforcement as they were helpless before the massive attack."

    The militants, who were shouting "God is great" and "Long live the Taliban," killed six policemen, six Shiite Muslim prisoners -- one of whom was beheaded -- and two civilians, said Dera Ismail Khan's commissioner, Mushtaq Jadoon. Many hard-line Pakistani militants consider the country's Shiite minority to be heretics. The militants were armed with guns, bombs and grenades, and some were disguised in police uniforms.

    The militants used megaphones to call out the names of specific prisoners for whom they were looking. They broke open the cells and freed 253 prisoners, including 25 "dangerous terrorists," said Jadoon.

    Malik Mohammad Qasim, a civilian prison adviser for surrounding Khyber Pakhtunkhwa province, said at least 38 of the prisoners who escaped had either been convicted or were on trial for terrorism charges.

    The attack ended at about 4 a.m. when the militants and prisoners fled the compound, said intelligence officials. Authorities declared a curfew in the area and started searching for both the militants and the prisoners. Dera Ismail Khan is located near Pakistan's tribal region, the main sanctuary for Taliban and al-Qaida militants in the country, and many may have fled there.

    The militants left behind four suicide vests, two rocket-propelled grenades and 50 hand grenades, said Inayatullah Khan, head of the police bomb disposal squad in Dera Ismail Khan.

    Pakistani Taliban spokesman Shahidullah Shahid claimed responsibility for the attack, saying 150 militants took part-- a number backed up by Pakistani officials -- and around 300 prisoners were freed. Eight of the attackers wore suicide vests, and two detonated their explosives, Shahid told The Associated Press by telephone from an undisclosed location.

    Khalid Abbas, a policeman who heads the prison department in Khyber Pakhtunkhwa, said officials recently received intelligence indicating a possible attack, but they didn't expect it so soon.

    Pervaiz Khattak, the chief minister of Khyber Pakhtunkhwa, said nobody informed him about a possible attack and he didn't understand how so many heavily armed militants could pass through so many security checkpoints.

    "It is an intelligence failure. Just a day before, I was given a report of all is good about prison security," said Qasim. "Heads will roll. No one will be spared."

    In April 2012, Taliban militants 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" insurgents.

    One of the militants freed in that attack, Adnan Rasheed, was the mastermind of the latest prison break and spent months planning it, said a Taliban commander, speaking on condition of anonymity for fear of being targeted by the government.

    Rasheed recently gained attention by writing a letter to teenage education activist Malala Yousafzai, who was shot in the head by the Taliban last year in an attempt to kill her. Rasheed said he wished the attack hadn't happened, but told Malala that she was targeted for speaking ill of the Taliban.