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.
Kate Middleton recycles dress at movie premiere
Gal Gadot cast as Wonder Woman for 'Batman vs. Superman'