Seven people were killed when attackers mounted a bomb, grenade and gun assault on the main prison in Yemen's capital on Thursday in a failed attempt to free inmates, authorities and witnesses said.

Explosions and gunfire between security forces and the attackers could be heard several kilometres away from the prison in northern Sanaa, which has al Qaeda members among its inmates. The biggest explosion rattled windows in the area.

"A terrorist group attacked the central prison," the ministry said in a statement published by state news agency SANA, adding that there was a car bomb followed by a gun attack on the facility.