More than 150 heavily-armed militants stormed the central prison outside the restive northwestern town of Bannu bordering the lawless tribal regions where Taliban and Al-Qaeda linked militants are known to operate.
Ehsanullah Ehsan, spokesman for the Tehreek-e-Taliban Pakistan (TTP) militant group claimed responsibility for the attack.
"We attacked the Bannu prison and got our special members freed," Ehsan told AFP.
"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."
The attack started at around 1:00 am and continued for two hours, with militants in cars and pick-up trucks shooting and lobbing grenades to force their way into the prison, a security official told AFP.
"Some 384 prisoners, including some hardcore militants, have escaped during the attack," the official said, asking not to be named.
"Preliminary information suggests that there were some 944 prisoners in the jail according to the tally late Saturday."
Information minister for Khyber Pakhtunkhwa province, Mian Iftikhar Hussain, told AFP there were "at least 20 dangerous prisoners and some militants", among the escapees.
"We will investigate why militants were able to carry out such an attack successfully and what the security was doing," he said.
Hussain said the militants blocked all roads leading to the prison to delay the arrival of any reinforcements and targeted six barracks where "dangerous insurgents" were being kept.
Security forces cordoned off the area and arrested some of the escapees, while others returned voluntarily saying they had fled to avoid the gunfire, Hussain said.
A large number of militants had recently been moved to the jail from neighbouring Kohat and Lakki Marwat prisons, which are being converted into centres to rehabilitate former insurgents, the security official said.
A former member of the airforce sentenced to death for an attack on former president Pervez Musharraf was among the escaped militants, he said.
Adnan Rasheed was convicted after a bomb planted under a bridge in Rawalpindi near Islamabad in December 2003 exploded moments after the passing of Musharraf's motorcade. His appeal is pending before the Supreme Court.
Authorities have shut down the mobile phone network in the area and army troops along with paramilitary forces and police have launched a search operation in the area, he said.
Police confirmed the attack but did not give any figures for the escapees, saying they were still investigating.
Senior Bannu police official Iftikhar Khan told AFP that at least three police officials were wounded in the attack.
The attackers outnumbered the security forces at the prison and militants fled before reinforcements reached the jail, he said.
"Some five escapees have handed themselves over to authorities, while six others were arrested during the search," Khan said.