The Iraqi city of Ramadi has been "liberated" from so-called Islamic State, the Iraqi military has declared.
Spokesman Brig Gen Yahya Rasul said forces had achieved an "epic" victory. TV pictures showed troops raising the Iraqi flag over the government complex.
Some reports indicate there are still pockets of resistance in the city.
The BBC's Thomas Fessy, in Ramadi, says the week-long battle against IS has destroyed the urban landscape.
Ramadi's recapture marks a major reversal for the jihadist group. They seized it in May, in an embarrassing defeat for the army.
Iraqi government forces have been fighting to retake it for weeks.
State television 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 Sunday, flushing out or killing IS 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 IS fighters had "planted more than 300 explosive devices on the roads and in the buildings of the government complex".
Iraqi Prime Minister 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 [IS's] 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 IS control in northern Iraq.
At the scene: Thomas Fessy, BBC News, Ramadi
Driving through Ramadi is a ride through the remains of a city ravaged by war.
This a place that has suffered over a decade of sporadic conflict, but the week-long battle against so-called Islamic State has destroyed the urban landscape.
Iraqi forces have cleared the main streets but no-one dares to step onto the rubble or enter the shattered buildings - booby traps are everywhere.
Ramadi sits on the Euphrates river, and we saw three of its bridges that had been cut in half - massive chunks of concrete lost in the water.
At the university campus, every single building is either destroyed or severely damaged. There was intense fighting here last week - IS militants had taken position within the campus. Some of the buildings were entirely flattened by coalition air strikes.
Operations are still under way in the city centre and in the northern quarters, where Iraqi troops supported by coalition warplanes are hunting retreating IS militants. But in the neighbourhoods that we visited, there was no sign of life except for the soldiers standing guard.
Iraqi troops are close to victory in Ramadi, but this is a city that has been sacrificed in battle.
The operation to recapture Ramadi, about 55 miles (90km) 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".