Security forces have recaptured parts of Heet, which was one of the largest population centers 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) organization, 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.
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 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.
The Islamic State of Iraq and the Levant, alternatively translated as Islamic State of Iraq and Syria or Islamic State of Iraq and al-Sham, is a Salafi jihadist militant group that follows an Islamic fundamentalist, Wahhabi doctrine of Sunni Islam. The group is also known as Daesh.
The term "jihadism" was coined in the 2000s and mostly used to cover Islamic insurgency and Islamic terrorism since that time, but it has also been extended to cover both Mujahideen guerilla warfare and Islamic terrorism with an international scope since it arose in the 1980s, since the 1990s substantially represented by the al-Qaeda network.
Contemporary jihadism ultimately has its roots in the late 19th- and early 20th-century ideological developments of Islamic revivalism, developed into Qutbism and related ideologies during the mid 20th century.
The Soviet invasion of Afghanistan in 1979 reinforced the rise of jihadism, which has been propagated in various armed conflicts throughout the 1990s and 2000s.
Gilles Kepel has diagnosed a specifically Salafi jihadism within the Salafi movement of the 1990s.