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.
Ramadi's recapture would mark a major reversal for the jihadist group. They had seized it in May, in an embarrassing defeat for the army.
Iraqi government forces had 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 had managed to capture the government compound on Sunday, flushing out or killing Islamic State (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".
Despite the declaration of victory, the head of military operations in Anbar, Gen Ismail al-Mahlawi, said retreating IS militants still controlled parts of the city, the Associated Press news agency reported.
The operation to recapture Ramadi, about 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".