BAGHDAD — Prime Minister Haider al-Abadi of Iraq declared victory over the Islamic State on Saturday, announcing the end of more than three years of battles to regain control over nearly one-third of the country that had been under the terrorist group’s dominion.

Mr. Abadi’s carefully calibrated statement came months after armed forces wrested back control over Iraq’s major urban areas, notably its second-largest city, Mosul, and shifted focus to mopping up remnants of the militants who had escaped or gone underground in the vast desert border areas between Iraq and Syria.

“Our forces fully control the Iraqi-Syrian border, and thus we can announce the end of the war against Daesh,” Mr. Abadi said, using the Arabic acronym for the Islamic State, known as ISIS or ISIL.

“Our battle was with the enemy that wanted to kill our civilization, but we have won with our unity and determination,” he said.