Taliban insurgents realised more than 400 prisoners after storming a mud fort being used as a jail in Ghazni.
A relief force of troops was beaten off following the raid although 80 inmates were recaptured, according to officials.
The latest Taliban prison break comes after setbacks for the government in different parts of the country and deadly attacks in Kabul which have dashed hopes for peace talks.
A Reuters reporter outside the prison in Ghazni, 120 km (75 miles) southwest of the capital, Kabul, saw the bodies of two men who appeared to be suicide bombers and a blown-up car that had apparently been used to destroy the main entrance.
Mohammed Ali Ahmadi, deputy city governor, said more than 400 prisoners had escaped. About 80 had been recaptured and 352 were on the run, including about 150 Taliban.
Seven Taliban and four members of the security forces were killed in the attack, he said.
“Roads to the prison were covered with land mines in advance to avoid reinforcement,” Ahmadi told reporters.
“An army vehicle coming for reinforcements was blown up by a roadside bomb while trying to reach the prison.”
Ahmadi said the prison did not have heavy security because it was so close to Ghazni – only seven km (4.3 miles) from the city centre – and it was believed that reinforcements would get there quickly in the event of trouble.
One security official said the attackers, armed with rocket-propelled grenades and automatic rifles, were wearing Afghan security force uniforms.
Taliban spokesman Zabihullah Mujahid said gunmen and three suicide bombers attacked the prison at 2 a.m. (2200 GMT Sunday). Three bombers were killed, he said.
“Forty Afghan security forces and prison guards were killed in the prison break and important military mujahideen officials have been freed,” he said, referring to Islamist fighters.
The Taliban often exaggerate casualty tolls in statements about their attacks.
The Taliban are fighting to overthrow the foreign-backed government of President Ashraf Ghani, expel foreign forces from Afghanistan and impose a strict interpretation of Islamic law.
The insurgents have on several occasions attacked jails to free hundreds of prisoners including their comrades in both Afghanistan and neighbouring Pakistan.
Security at the prisons is often poor, with untrained, poorly equipped police guarding crumbling facilities.