SUNNI rebels have battled their way into the biggest oil refinery in Iraq as the president of neighbouring Iran raised the prospect of intervening in a sectarian war that threatens to sweep across Middle East frontiers.

Sunni fighters were in control of three-quarters of the territory of the Baiji refinery north of Baghdad - the biggest source of fuel for domestic consumption in Iraq - after heavy fighting at gates defended by elite troops, who have been under siege for a week.

Taking full control of the refinery would give the rebels a firm grip on energy supply in the north, where the local population has complained of fuel shortages.

Loading article content

Militants have managed to break into the refinery and are now in control of the production units.

A lightning advance has seen Sunni fighters rout the Shi'ite-led government's army and seize the main cities across the north of the country since last week.

The fighters are led by the Islamic State of Iraq and the Levant (ISIL), which aims to build a Sunni caliphate (sovereign nation state) ruled on mediaeval precepts, but also include a broad spectrum of more moderate Sunnis furious at what they see as oppression by Baghdad.

Some international oil firms have pulled out foreign workers, with BP evacuating 20 per cent of its staff.

Officials in Washington and other Western capitals are trying to save Iraq as a united country by leaning hard on Shi'ite Prime Minister Nuri al-Maliki to reach out to Sunnis. He met Sunni and Kurdish political opponents and then appeared with them to read out an appeal for national unity.

Mr Maliki appealed to tribes to renounce "those who are killers and criminals who represent foreign agendas".

But so far Mr Maliki's government has relied almost entirely on his fellow Shi'ites for support, with officials denouncing Sunni political leaders as traitors. Shi'ite militia - many believed to be funded by Iran - have mobilised to halt the Sunni advance, as Iraq's million-strong army crumbles.

Iran's President Hassan Rouhani made the clearest declaration yet that the Middle East's main Shi'ite power, which fought a war against Iraq that killed a million people in the 1980s, was prepared to intervene to protect Iraq's great shrines of Shi'ite imams, visited by millions of pilgrims each year.

The Glasgow-educated president said: "We announce to the killers and terrorists that the great Iranian nation will not hesitate to protect holy shrines."

He said many people had signed up to go to Iraq to fight, although he also said Iraqis of all sects were prepared to defend themselves.

Iraqi troops are holding off Sunni fighters outside Samarra, north of Baghdad, site of one of the main Shi'ite shrines. The fighters have promised to carry their offensive south to Najaf and Kerbala, seats of Shi'ite Islam since the Middle Ages.

Saudi Arabia, the region's main Sunni power, said Iraq was hurtling towards civil war. Foreign Minister Prince Saud al-Faisal, in words clearly aimed at Iran and at Baghdad's Shi'ite rulers, deplored the prospect of "foreign intervention" and said governments need to meet "legitimate demands of the people".

Mr Maliki's government has accused Saudi Arabia of promoting "genocide" by backing Sunni militants. Riyadh supports Sunni fighters in Syria but denies aiding ISIL.