Iraqi Kurds have clashed with Sunni fighters over control of the northern Iraqi city of Kirkuk, as thousands of internally displaced refugees head away from the area to escape the swelling violence.

Kurdish Peshmerga forces fought with fighters from the Islamic State of Iraq and the Levant (ISIL) on Wednesday in an attempt to establish control over the northern city and its vast oil reserves, a potential high-value economic zone that Kurdish leaders believe can heavily boost their ambitions of a sovereign state.

Baghdad's military retreat from the north last week allowed Peshmerga forces of the Kurdistan Regional Government (KRG) to seize control of the disputed area.

Falah Mustafa, KRG's foreign minister, told Al Jazeera the fighting had ended and the area was secure with fighters pushed back.

"There were some problems in Bashir which is a predominantly Turkmen area and Mana Abdallah which is an Arab area, but Peshmerga forces defended the territories and now the situation is back to normal," he said.

The relatively calm, semi-autonomous region has taken in at least 300,000 people fleeing fighting in the northern city of Mosul.

Fighting has engulfed much of the north, with the ISIL seizing control of Iraq's largest oil refinery after a successive day of heavy clashes.

The fighters laid siege to the Baiji facility, about 210km north of Baghdad, threatening to cut off the country's domestic oil supplies.

A senior manager of the state-owned North Oil Company said the fighters attacked parts of the refinery complex, leading to casualties among security forces personnel.

The Baiji refinery accounts for a little more than a quarter of the country's entire refining capacity, all of which goes towards domestic consumption for things like petrol, cooking oil and fuel for power stations.

Any lengthy power cut at Baiji risks long lines at the petrol pump and electricity shortages, adding to the woes already facing the country.

The refinery was shut down on Tuesday and foreign staff evacuated as the major towns seized by the ISIL, including the second largest city, Mosul, were no longer being supplied with refined oil products.

Iran weighs in

Iran's President Hassan Rouhani has said he will do whatever it takes to protect revered Shia shrines from the rebels.

In a speech near the Iraq border, Rouhani promised Iranians would do "everything to protect them".

Rouhani made reference to petitions signed by Iranians who were willing to fight in Iraq "to destroy the terrorists and protect the holy sites", which are visited by hundreds of thousands of Iranian pilgrims annually.

At least 5,000 Iranians have pledged online to defend Iraq's Shia shrines against the Sunni extremists, a conservative news website in Iran reported.

Meanwhile, Saudi Arabia said Iraq faced the threat of full-scale civil war with grave consequences for the wider region.

Prince Saud al-Faisal, the Saudi foreign minister, told a gathering of Arab and Muslim leaders in Jeddah that "this grave situation that is storming Iraq carries with it the signs of civil war whose implications for the region we cannot fathom".

The Saudis blamed the Iraqi crisis on Iraqi Prime Minister Nouri al-Maliki on Monday, citing what it called years of "sectarian and exclusionary policies" by his government against the Sunni minority.