In capturing city of Heet, security forces stumble on massive underground jail and free prisoners, most of them civilians.

Iraqi forces freed a large number of prisoners from an underground Islamic State (ISIS) group jail during a battle to retake a western town from the jihadists, officials said on Saturday.

Security forces have recaptured parts of Heet, which was one of the largest population centers in Anbar province still held by ISIS, but other areas remain under jihadist control.

"During their advance to liberate and clear the town of Heet from the (ISIS) organization, security forces were able to discover a large prison," said police Colonel Fadhel al-Nimrawi.

"The prison was underground" and held 1,500 people, who were freed by security forces, Nimrawi said.

Malallah al-Obeidi, a local official in Anbar, also put the number of freed prisoners at around 1,500, saying most of them were civilians.

Muhannad al-Dulaimi, the official responsible for the Heet area, also confirmed the discover of a "large prison" in the town, but did not say how many people it held.

ISIS overran large areas north and west of Baghdad in 2014, but security forces have since regained significant ground from the jihadists.

After the recapture of Anbar provincial capital Ramadi, Heet and the city of Fallujah were two of the largest population centers still held by jihadists in Anbar.

Iraq began a broad offensive to retake Heet in mid-March, but a significant number of troops were pulled out of Anbar to protect protesters in Baghdad, which may have delayed the drive.

AFP contributed to this report.