At least four police officers were killed during the raid and the Taliban confirmed it carried out the early morning attack in the city of Ghazni.
Taliban spokesman, Zabihullah Mujahid said a group of 10 Taliban bombers raided the prison and attacked troops before releasing around 400 inmates.
He said the bombers started the attack on jail and the nearby military base with the help of scores of other fighters.
“The successful operation started at 2 am and continued for few hours. The Mujahideen took control of the whole prison and the Mujahideen killed many soldiers and jail guards,” he said in a Pashto-language statement sent to Channel 4 News.
“We freed 400 oppressed countrymen as the result of the attack. The inmates had been subjected to severe torture and brutality. The Mujahideen have returned to their areas,” the Taliban spokesman continued.
The deputy provincial governor of Ghazni province Mohammad Ali Ahmadi condemned the attack. He said one militant blew himself up at the prison gates, allowing others to force open jail cells. Car bombs and rockets were also used to open the gates.
Mr Ahmadi said the Taliban fighters were wearing military uniform and seven of them were killed, in addition to four members of the security forces.
About 80 prisoners have been recaptured, however 352 are still on the run, including 150 Taliban.
The militant group has previously carried out major attacks on prisons to free inmates. In 2011, the Taliban attacked Kandahar prison and freed 500 prisoners.