Security forces have recaptured parts of Heet, which was one of the largest population centres in Anbar province still held by IS, but other areas remain under jihadist control.
"During their advance to liberate and clear the town of Heet from the (IS) organisation, security forces were able to discover a large prison," police Colonel Fadhel al-Nimrawi.
"The prison was underground" and held 1,500 people, who were freed by security forces, Nimrawi said.
Signup to our newsletter and follow us on Facebook and Twitter!
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 discovery of a "large prison" in the town, but did not say how many people it held.
IS 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 centres 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.