A local government official said the militants, disguised in security uniforms, stormed the building during a transfer of inmates from one jurisdiction to another, China's state-run Xinhua News Agency reported.
Witnesses said the attackers tried to free the prisoners and exchanged gunfire with security personnel. During the confrontation, the attackers lobbed hand grenades, killing six people at the scene.
Xinhua said several reports indicated another militant detonated his explosive jacket when security personnel tried to arrest him.
No one immediately claimed responsibility for the attack.
Exploding whale video goes viral on Internet
Benedict Cumberbatch's dramatic reading of R. Kelly lyrics is just what you need