The quick advance by ISIL in Iraq began in 2014.
Iraqi Prime Minister Haider al-Abadi has declared the end to the country's war against the Islamic State of Iraq and the Levant (ISIL, also known as ISIS) group.
"Our forces are in complete control of the Iraqi-Syrian border and I therefore announce the end of the war against Daesh," al-Abadi told a conference in Baghdad on Saturday, using the Arabic acronym for ISIL.
The announcement followed the recapture of Rawa, one of the last remaining ISIL-held towns, in November.
Since then, Iraqi forces had been fighting to retake the small pockets in the border area that were still under ISIL control.
Earlier on Saturday, senior military commander Lt General Abdul Ameer Rasheed Yarallah had announced the end of the fight against ISIL saying that "all Iraqi lands are liberated from terrorist Daesh gangs and our forces completely control the international Iraqi-Syrian borders".
Just six months ago, ISIL still controlled vast expanses of territory, including major cities, on both sides of the Iraq-Syria border.
The group captured important cities like Mosul, Ramadi and Fallujah.
In early November, Iraqi forces announced the recapture of al-Qaim, ISIL's last border stronghold in the country.
Saturday's announcement marks the end of the three-year war to drive ISIL out of Iraq.
Brett McGurk, US special envoy for the coalition against ISIL, congratulated Iraq on Twitter.
"We congratulate the prime minister and all the Iraqi people on this significant achievement, which many though impossible," McGurk said.
The Global Coalition, which as been supporting Iraqi forces in their fighter against ISIL, added that it will continue to "stand by them [Iraqis] as they set the conditions for a secure and prosperous future [in] Iraq".
Last month, al-Abadi said that the losses from the war against ISIL had cost $100bn.
SOURCE: AL JAZEERA NEWS