MOSUL/ERBIL, Iraq (Reuters) - Iraq's prime minister declared victory over Islamic State in Mosul on Monday, three years after the militants seized the city and made it the stronghold of a "caliphate" they said would take over the world.
"I announce from here the end and the failure and the collapse of the terrorist state of falsehood and terrorism which the terrorist Daesh announced from Mosul," Haider al-Abadi said in a speech shown on state television, using an Arabic acronym for Islamic State.
A 100,000-strong alliance of Iraqi government units, Kurdish Peshmerga fighters and Shi'ite militias launched the offensive to recapture the northern city from the militants in October, with key air and ground support from a U.S.-led coalition.
Abadi, wearing a black military uniform and flanked by commanders from the security forces, thanked troops and the coalition. But he warned that more challenges lay ahead.
"We have another mission ahead of us, to create stability, to build and clear Daesh cells, and that requires an intelligence and security effort, and the unity which enabled us to fight Daesh," he said before raising an Iraqi flag.
Iraq declared a week-long holiday to mark the victory. People celebrated in the streets of the capital Baghdad and southern cities.
Abadi arrived in Mosul on Sunday to congratulate military commanders who have waged a nearly nine-month battle to recapture the city, many parts of which were reduced to rubble.
Gunfire and explosions could be heard earlier in the day as the last few Islamic State positions were pounded.
The coalition said in a statement Iraqi forces were in "firm control" of Mosul, but some areas still needed to be cleared of explosive devices and possible Islamic State fighters in hiding.
Around the time of Abadi's announcement, Islamic State released a statement claiming to have mounted an attack on Iraqi forces in Mosul. Reuters could not immediately verify the report.
Abadi had been meeting military and political officials in Mosul in an atmosphere of celebration that contrasts with the fear that spread after a few hundred Islamic State militants seized the city and the Iraqi army crumbled in July 2014.
Islamic State leader Abu Bakr al-Baghdadi shocked the Middle East and Western powers three years ago by appearing at the pulpit of Mosul's Grand al-Nuri Mosque to declare the caliphate and himself the leader of the world's Muslims.
A reign of terror followed which eventually alienated even many of those Sunni Muslims who had supported the group as allies against Iraq's Shi'ite majority. Opponents of Islamic State were executed and such crimes as smoking a cigarette were punishable by public whipping.
Since the 2003 U.S.-led invasion that toppled Saddam Hussein, the Shi'ites have been politically dominant in Iraq but the country has been racked by ethnic conflict.
(For a graphic on destruction in Mosul, click tmsnrt.rs/2sV2emM)
In the aftermath of victory in Mosul, Abadi's government faces the task of managing the sectarian tensions there and elsewhere that enabled Islamic State to win support, and the threat of a wave of revenge violence in the city.
The coalition warned that victory in Mosul did not mark the end of the group's global threat.
"Now it is time for all Iraqis to unite to ensure ISIS (Islamic State) is defeated across the rest of Iraq and that the conditions that led to the rise of ISIS in Iraq are not allowed to return again," Lt. Gen. Stephen J. Townsend said in a statement.
U.S. President Donald Trump congratulated Iraq and said Islamic State's days were numbered. Secretary of State Rex Tillerson called the victory "a critical milestone" in the war against Islamic State.
Baghdadi has fled the city and his whereabouts are unknown. Reports have circulated that he is dead but Iraqi and Western officials say they cannot corroborate this.
His death or capture would not be the end of Islamic State, which still controls areas south and west of Mosul and which is now expected to take to the desert or mountains to wage an insurgency.
The militants are likely to keep trying to launch attacks on the West and inspiring violence by "lone wolves" or small groups of the kind mounted recently in Britain, France and elsewhere.
But the loss of Iraq's second-largest city is a grave body blow to Islamic State.
Islamic State is also under heavy pressure in its operational headquarters in the Syrian city of Raqqa. But a concern shared by the United States and its coalition allies is that Iran could fill the vacuum left by the Sunni militants to expand in both Iraq and Syria.
Qassem Soleimani, head of the Quds Force, the extraterritorial branch of Shi'ite Iran's Islamic Revolutionary Guard Corps, said on Monday Iran had sent "thousands of tonnes" of arms and fighter jets to Iraq to help it fight Islamic State, Iranian media reported.
The stench of corpses along Mosul's streets was a reminder of the gruelling urban warfare required to dislodge Islamic State.
Much of the city of 1.5 million has been destroyed in the fighting, its centuries-old stone buildings flattened by air strikes and other explosions. One of Islamic State's last acts was to blow up the historic al-Nuri mosque and its famous leaning minaret.
Thousands of people have been killed. The United Nations says 920,000 civilians have fled their homes since the military campaign began in October. Close to 700,000 people are still displaced.
"It's a relief to know that the military campaign in Mosul is ending. The fighting may be over, but the humanitarian crisis is not," said U.N. Humanitarian Coordinator for Iraq Lise Grande."Many of the people who have fled have lost everything. They need shelter, food, health care, water, sanitation and emergency kits. The levels of trauma we are seeing are some of the highest anywhere. What people have experienced is nearly unimaginable."
Iraqi soldiers relaxed. Some swam in the Tigris river which runs through the city. One wiped the sweat from his face with an Islamic State flag.
Writing by Michael Georgy; Editing by Andrew Roche