The Iraqi military has declared the city of Ramadi “liberated” from ISIS.
Spokesman Brig. Gen. Yahya Rasul said forces had achieved an “epic” victory.
TV footages showed troops raising the Iraqi flag over the government complex.
However, some reports indicate there are still pockets of resistance in Ramadi.
Ramadi’s recapture marks a major reversal for the jihadist group. ISIS seized Ramadi in May, in an embarrassing defeat for the army.
Iraqi government forces have been fighting to retake it for weeks.
State TV showed pictures of soldiers in Ramadi firing their guns in the air and publicly slaughtering a sheep in celebration.
Troops managed to capture the government compound on December 27, flushing out or killing ISIS fighters and suicide bombers who had been holding out in its buildings.
Brig. Gen. Majid al-Fatlawi of the army’s 8th division told AFP that ISIS fighters had “planted more than 300 explosive devices on the roads and in the buildings of the government complex”.
Iraqi PM Haider al-Abadi praised the capture of Ramadi in a TV address.
“2016 will be the year of the big and final victory, when Daesh’s [ISIS’] presence in Iraq will be terminated,” he said.
“We are coming to liberate Mosul and it will be the fatal and final blow to Daesh,” he added, in a reference to the largest city under ISIS control in northern Iraq.
The operation to recapture Ramadi, about 55 miles west of Baghdad, began in early November.
It was backed by US-led coalition air strikes. But it made slow progress, mainly because the government chose not to use the powerful Shia-dominated paramilitary force that helped it regain the mainly Sunni northern city of Tikrit, to avoid increasing sectarian tensions.
The US military called the recapture a “proud moment for Iraq”.
It added that “the coalition will continue to support the government of Iraq as they move forward to make Ramadi safe for civilians to return”.