Iraqi security forces have entered the country's largest refinery for the first time after months of battling fighters who had surrounded it, according to Iraqi officials.

A statement issued on the official Facebook page of Iraq's Prime Minister on Wednesday said Haidar al-Abadi "congratulated the armed forces, the popular crowds backing it and all sons of Iraq on the impressive victories it achieved by fully liberating the city of Beiji, and opening the land route from Baghdad to the Beiji [oil] refinery."

State television confirmed that the recovery of the Beiji facility from ISIL, or the Islamic State of Iraq and the Levant, could provide critical momentum for government forces charged with restoring stability in the country.

"The first Iraqi force, the anti-terrorism force called Mosul Battalion, entered Beiji refinery for the first time in five months," police Colonel Saleh Jaber from the Beiji refinery protection force told Reuters news agency on Tuesday.

State television flashed news of the advance and broadcast footage it said was of Iraqi security forces entering the refinery's gate.

"In this area, terrorists were stationed to the left and right. If God is willing, Beiji will be the main key to liberating each span of Iraq," Abdel Wahab al-Saadi, the commander of provincial security operations, told the broadcaster.

US-led air attacks have prevented ISIL, which swept through northern Iraq in June almost unopposed by the Iraqi army, from making significant further territorial gains for its self-proclaimed caliphate.

Grain theft alleged

In a separate development, Reuters news agency quoted the Iraqi government as saying that ISIL fighters had stolen more than one million tonnes of grain from the country's north and taken it to two cities they control in neighbouring Syria.

Falah Hassan al-Zeidan, agriculture minister, said in a statement posted on the ministry's website on Sunday that the government "had information about the smuggling by Islamic State gangs of more than one million tonnes of wheat and barley from Nineveh province to the Syrian cities of Raqqa and Deir al-Zor".

Zeidan said the fighters considered the eastern Syrian cities "safe for them" and thus transferred wheat and barley in Nineveh "to preserve it"

.

When ISIL pushed from Syria into northern Iraq in June, they swiftly took over government grain silos in Nineveh and Salahuddin provinces, where about a third of Iraq's wheat crop and nearly 40 percent of the barley crop is typically grown.

The former head of Iraq's Grain Board of Iraq told Reuters in August that ISIL fighters had seized 40,000 to 50,000

tonnes of wheat in Nineveh and the western province of Anbar and transferred it to Syria for milling.

However, it is not known precisely how much wheat the fighters seized over the summer, as they forced hundreds of

thousands of people - including many farmers - off their land in what amounted to a purge of the ethnically and religiously diverse area.

The ISIL offensive coincided with the harvest of the strategic wheat crop there. Many farmers were unable to sell to the government or to private traders because of the conflict.

ISIL is hoping to make its self-proclaimed caliphate self-sufficient.