Retaking Beiji, 250 kilometres (155 miles) north of Baghdad, could allow Iraqi forces a base to attack neighbouring Tikrit, taken by the extremists after their lightning advance this summer.
It also represents a morale boost for Iraq's beleaguered security forces, which saw many of its troops flee the militant offencive.
State television quoted the top army commander in Beiji, Gen Abdul-Wahab al-Saadi, as saying troops recaptured the city's local government and police headquarters at the centre of the town.
Al-Saadi later spoke to state television by telephone but the line appeared to be cut off after he said his forces were meeting stiff resistance.
More From This Section
A senior military official reached by telephone in Beiji confirmed the recapture of the city centre, but added that intense clashes continued elsewhere in the town.
He told The Associated Press that 75 percent of Beiji was now in the hands of government troops. He spoke on condition of anonymity because he was not authorised to speak to journalists.
There was no word on the fate of the refinery, which lies on the outskirts of the town and has been besieged by Islamic State fighters since June.
The small army unit inside the refinery, resupplied and reinforced by air for months, successfully resisted wave after wave of extremist assaults.
Iraq's army and security forces partially have regrouped after melting away in the face of the summer's Islamic State offencive.
Recapturing Beiji also would be a major boost for Iraq's Shiite-led government and could pave the way for a fresh offencive to drive Islamic State militants from the nearby city of Tikrit, Saddam Hussein's hometown and the capital of Salahuddin province.