A photo on Abadi's official Twitter account showed him dressed in a black military uniform and cap as he arrived in Mosul.
Abadi "arrives in the liberated city of Mosul and congratulates the heroic fighters and the Iraqi people on the achievement of the major victory," his office said in a statement.
A photo on Abadi's official Twitter account showed him dressed in a black military uniform and cap as he arrived in Mosul to announce the recapture of the city.
The fighting did not seem to be completely over yet, with gunfire still audible in Mosul and air strikes hitting the city around the time the premier's office released the statement.
Iraqi forces launched the Mosul operation in October, first fighting their way to the city, retaking its east and then assaulting its western side, where some of the heaviest fighting occurred.
The battle has taken a heavy toll on civilians, pushing more than 900,000 people to flee their homes, only a fraction of home have returned, according to the United Nations.
And security forces have also suffered heavy losses, with thousands killed and wounded, though official casualty figures have not been released by Iraqi authorities.
IS overran large areas north and west of Baghdad in 2014, but Iraqi forces backed by US-led air strikes have since regained much of the territory they lost.
The recapture of Mosul does not however mark the end of the threat posed by IS, which holds territory elsewhere in Iraq and is able to carry out frequent bombings in government-held areas.