Prime Minister Haider al Abadi said the country’s armed forces were in “complete control” of the Iraqi-Syrian border which contained the last few areas held by IS.
It comes two days after Russia said its mission supporting the Syrian regime to oust IS jihadists had been “accomplished”.
Mr Abadi told a conference in Baghdad: “Our forces are in complete control of the Iraqi-Syrian border and I therefore announce the end of the war against Daesh (IS).
“Our enemy wanted to kill our civilisation, but we have won through our unity and our determination. We have triumphed in little time.”
Mrs May said: “On behalf of the United Kingdom, I congratulate Prime Minister Abadi and all Iraqis on this historic moment. I pay tribute to the Iraqi Security Forces for their courage and sacrifice.
“Daesh no longer hold significant territory in Iraq or Syria. This signals a new chapter towards a more peaceful, prosperous country.
“I am proud that the UK, as a leading member of the Global Coalition, has stood shoulder-to-shoulder with Iraq to help them open that chapter. I saw the effects of this first hand when I visited last week.”
IS seized large swathes of Syria and Iraq in 2014, with some 10 million people living in territory under its control at its peak.
Foreign fighters, including dozens of Britons, flocked there, travelling mostly through Turkey, to live under the so-called caliphate declared by IS leader Abu Bakr al Baghdadi.
The jihadist group carried out a campaign of terror in the region including beheadings, hangings, public floggings and the torture of prisoners.
Iraq’s fightback, backed by an air campaign waged by a US-led coalition, began with the “liberation” of Tikrit – the hometown of Saddam Hussein – in March 2015 after it had been under IS control for nearly 10 months.
IS lost Iraq’s second city of Mosul in July this year and its de facto capital of Raqqa in northern Syria in November.
More from World
Two Palestinians killed in Israel airstrike, Gaza officials say
Johnson in ‘two hours of frank talks’ with Iran
Kim Jong Un celebrates missile launch with stroll on sacred mountain
Thousands of fans and celebrities bid au revoir to ‘French Elvis’ Johnny Hallyday
Mummy discovered in unexplored Egyptian tomb
California wildfires hit ‘avocado capital of the world’
But the allied victory has come at an incalculable cost. More than 40,000 people died in Mosul alone and large parts of Iraq have been wrecked.
In a statement on Twitter, the US-led coalition said: “Congratulations to the government of Iraq and the Iraqi security forces on the liberation of all Daesh-held populated areas in Iraq.”