Almost 400 prisoners have escaped from a prison in Pakistan after it was attacked by Islamist militants.

At least 100 militants launched the assault on the jail in north-west Pakistan at 01:00 (20:00 GMT Saturday).

Officials said some of the freed men were "dangerous" insurgents, including an inmate on death row for trying to kill ex-President Pervez Musharraf.

The jail is located in Bannu, a town in Khyber Pakhtunkhwa, which borders Pakistan's volatile tribal areas.

The BBC's Aleem Maqbool in Islamabad says the attack is clearly a setback for Pakistan's security forces, who over the last year have gained considerable ground against militants in the north-west of the country.

'Throwing grenades'

Pakistan's Taliban said they carried out the attack, but the claim has not been verified.

At the scene At the jail workmen toiled with blow torches and hammers to try to repair the massive black gates punctured by hand grenades and rockets as the Taliban made their entrance. Local officials are demanding to know how such a brazen assault could have taken place in a supposedly secure location. The answer, it seems, is that it may have been surprisingly easy. Prison staff say they were too poorly armed to defend the jail themselves, and the police and army were too slow in responding to pleas for help. An assistant superintendent at the jail told us they made several calls but no-one turned up for an hour and a half. By the time they came, it was too late, he said, as he stood in a burnt-out office surrounded by charred prison record books. We saw two prisoners strolling back into the jail, looking relaxed at returning to their cells. They were checked briefly at the entrance before a warden walked them inside. They were among about 30 who have turned themselves in so far. It's believed that some haven't much time left to serve.

"We attacked the Bannu prison and got our special members freed," Ehsanullah Ehsan, a Taliban spokesman, told Agence France-Presse.

"In a couple of days when all of them have reached their designated places we will issue details about them. At the moment I cannot give you exact numbers."

Officials described how militants in cars and pick-up trucks entered the complex shooting and throwing grenades.

One inmate still in the jail, Malik Nazeef, told Reuters by telephone: "I don't remember the exact time, but it must have been way past midnight. There were huge explosions. Plaster from the ceilings fell on us. Then there was gunfire. We didn't know what was happening."

Senior Bannu police official Iftikhar Khan told AFP that three police officers were wounded in the two-hour attack.

A total of 384 prisoners were freed, the information minister of Khyber-Pakhtunkhwa province, Mian Iftikhar Hussain, said.

The prison was housing a number of insurgents transferred from prisons in Kohat and Lakki Marwat which are undergoing renovation.

Mr Hussain described at least 20 of the escaped prisoners as very dangerous, and that Adnan Rashid, a former member of the air force sentenced to death for an attack on Mr Musharraf, was among those who fled.

Mr Hussain said the insurgents had blocked all the roads leading to the jail to prevent the early arrival of reinforcements.

He said a cordon was thrown around the jail after the escape and that a number of inmates had been captured, while others had given themselves up seeking safety from the exchanges of gunfire with security forces.

The BBC's Orla Guerin, at the scene, says she saw no sign of any large-scale search operation on the roads around Kohat. In Bannu itself she says she saw only one attempt at a checkpoint - a lone policeman partially blocking one lane of traffic with a few upturned bricks.

On a five-hour drive from Islamabad to Bannu, our correspondent says she passed through only one checkpoint - hours from the jail.

The Taliban carried out an audacious jail raid near Kandahar in Afghanistan in April last year, freeing at least 470 prisoners, including Taliban commanders and fighters.