The town of Hawija and the surrounding areas fell in an offensive by U.S.-backed Iraqi government troops and Iranian-trained and armed Shi‘ite paramilitary groups known as Popular Mobilisation.
Some fighting took place to the north and east of the town where the militants were surrounded.
With the fall of Hawija, which lies near the Kurdish-held oil city of Kirkuk, the only area that remains under control of Islamic State in Iraq is a stretch alongside the western border with Syria, where the militant group is also in retreat.
The capture of Hawija was a boost for the Iraqi government, which faces a separate crisis in the north of the country, where the Kurdish minority last month voted overwhelmingly in support of independence for their autonomous region.