Taliban militants have freed 248 prisoners in an assault on a prison in north-west Pakistan, officials say.
Militants armed with automatic weapons, rocket-propelled grenades, mortars and bombs blasted down the walls of the jail in the town of Dera Ismail Khan and streamed inside, reports said.
A gun battle lasting several hours went on into the early hours of Tuesday. At least 13 died, including six police.
Correspondents say it is a huge embarrassment for authorities.
The attack was similar to an assault on a prison in nearby Bannu in April last year, in which almost 400 prisoners were freed.
Reports also suggest intelligence had warned of an impending attempt on the jail two weeks ago.
This latest assault demonstrates the weakness of the Pakistani state, says the BBC's Shahzeb Jillani in Karachi.
The state appears not to have the capacity, and some would say the will, to rein in hardened militants, he says.
The attack in the town of Dera Ismail Khan began with shooting and huge explosions at around midnight on Monday (15:00 GMT).
Up to 100 attackers, some wearing police uniforms, bombarded the prison with rockets and mortars before going inside.
The town's civil commissioner, Mushtaq Jadoon, said attackers used loudhailers to call the names of particular inmates.
An ensuing gun battle raged for three or four hours.
Katherine Houreld, a correspondent for Reuters news agency, told the BBC it had been a "very sophisticated attack - they blew the electricity line, they breached the walls and they set ambushes for reinforcements".
"When the shooting started, we immediately got into an armed police vehicle and parked on the road in front of the main gate," injured policeman Hidayat Ullah told AP news agency from his hospital bed.
"After this, we heard an explosion and the main gate exploded. After this, we started shooting towards the main gate from our armed vehicle.
"During this time, maybe either a rocket launcher or a mortar shell hit the vehicle. Two of our policemen were killed on the spot, and three of us were injured. We got down from the armed vehicle, and after that I don't know what happened."
The town's prison is a century old and is said not to have been designed for high-security inmates, but houses hundreds of Taliban fighters and militants from other banned groups.
Mr Jadoon said 30 "hardened militants", who had been jailed for their involvement in major attacks or suicide bombings, were among those freed.
He was also quoted as saying that militants had taken away six women, five of them inmates and the other a police officer.
An unnamed official told AFP news agency that jail records and an office had also been torched.
The town is in Khyber Pakhtunkhwa Province, next to Pakistan's mountainous tribal region.
Among the inmates freed were two local Taliban commanders, Abdul Hakim and Haji Ilyas.
Also released is a sectarian militant, Waleed Akbar, the principle suspect in last year's attacks on Shia mourners in Dera Ismail Khan during the Shia mourning month of Moharram.
Fourteen fugitives were later re-arrested by police, Mr Jadoon said.
A curfew has now been imposed on Dera Ismail Khan as police hunt for the remaining escaped prisoners, but correspondents say this will be a difficult task as they flee into tribal areas.
Mr Jadoon told a local TV station that militants had booby-trapped the building with explosive devices, which had now been defused.
The chief minister of Khyber Pakhtunkhwa province, Pervez Khattak, branded the incident a failure of several agencies.
A local resident told the agency that the initial blast was so loud that "it rattled every house in the neighbourhood".
The attackers were chanting "God is great" and "Long live the Taliban", officials said.
Pakistani Taliban spokesman Shahidullah Shahid said his group carried out the attack. He said about 300 prisoners had been freed.
The authorities are reported to have received intelligence about an impending attack two weeks ago, but prison officials said they did not expect it to come so soon.
A Taliban spokesman said one of their commanders freed in an assault on a prison in Bannu in northern Pakistan in April last year played a key role in the latest jailbreak.
Correspondents say the authorities will face questions about how militants were able to stage a virtually identical attack in Dera Ismail Khan.
Monday night's violence came hours before Pakistani politicians elected Mamnoon Hussain from the ruling PML-N party as the country's new president.