REUTERS - U.S. Secretary of State John Kerry urged leaders of Iraq's autonomous Kurdish region on Tuesday to stand with Baghdad in the face of a Sunni insurgent onslaught that threatens to dismember the country.

Security forces fought Sunni armed factions for control of the country's biggest oil refinery on Tuesday and militants launched an attack on one of its largest air bases less than 100 km (60 miles) from the capital.

More than 1,000 people, mainly civilians, have been killed in less than three weeks, the United Nations said on Tuesday, calling the figure "very much a minimum".

The figure includes unarmed government troops machinegunned in mass graves by insurgents, as well as several reported incidents of prisoners killed in their cells by retreating government forces.

Kerry flew to the Kurdish region on a trip through the Middle East to rescue Iraq following a lightning advance by the Sunni fighters led by jihadis of the Islamic State in Iraq and the Levant.

U.S. officials believe that persuading the Kurds to stick with the political process in Baghdad is vital to keep Iraq from splitting apart. "If they decide to withdraw from the Baghdad political process it will accelerate a lot of the negative trends," said a senior State Department official who briefed reporters on condition of anonymity.

Kurdish leaders have made clear that the settlement keeping Iraq together as a state is now in jeopardy.

"We are facing a new reality and a new Iraq," Kurdish President Massoud Barzani said at the start of his meeting with Kerry. Earlier, he blamed Prime Minister Nuri al-Maliki's "wrong policies" for the violence and called for him to quit, saying it was "very difficult" to imagine Iraq staying together.

Kerry told Barzani that Iraq needed to stay united, a State Department official said, referring to the Kurdish leader's comments about wanting an independent state.

The official summarised Kerry's message as: "Whatever your aspirations are for your future, your interests now in the near-term are for a stable, sovereign and unified Iraq."

The five million Kurds, who have ruled themselves within Iraq in relative peace since the 1990s, have seized on this month's chaos to expand their own territory, taking control of rich oil deposits.

Two days after the Sunni fighters launched their uprising by seizing the north's biggest city Mosul, Kurdish troops took full control of Kirkuk, a city they consider their historic capital and which was abandoned by the fleeing Iraqi army.

The Kurds' capture of Kirkuk, just outside the boundary of their autonomous zone, eliminates their main incentive to remain part of Iraq: its oil deposits could generate more revenue than the Kurds now receive from Baghdad as part of the settlement that has kept them from declaring independence.

Some senior Kurdish officials suggest in private they are no longer committed to Iraq and are biding their time for an opportunity to seek independence. In an interview with CNN, Barzani repeated a threat to hold a referendum on independence, saying it was time for Kurds to decide their own fate.

New government

Washington has placed its hopes in forming a new, more inclusive government in Baghdad that would undermine the insurgency. Kerry aims to convince Kurdish leaders to join it.

In Baghdad on Monday Kerry said Maliki assured him the new parliament, elected two months ago, would sit by a July 1 deadline to start forming a new government. Maliki is fighting to stay in power, under criticism for the ISIS-led advance.

Baghdad is racing against time as the insurgents consolidate their grip on Sunni provinces.

The Baiji refinery, a strategic industrial complex 200 km (120 miles) north of Baghdad, remained a frontline early on Tuesday. Militants said late on Monday they had seized it, but two government officials said troop reinforcements had been flown into the compound and fended off the assault.

Local tribal leaders said they were negotiating with both the Shi'ite-led government and Sunni fighters to allow the tribes to run the plant if Iraqi forces withdraw. One of the government officials said Baghdad wanted the tribes to break with ISIS and other Sunni armed factions, and help defend the compound.

The plant has been fought over since last Wednesday, with sudden reversals for both sides and no clear winner so far.

In northeastern Iraq, violence continued between Sunni militants and Kurdish peshmerga fighters. Police in Diyala province said two peshmerga members were killed by a sniper and two wounded in Jalawla, 115 km (70 miles) northeast of Baghdad.

Police in Kirkuk said gunmen shot dead a local ethnic Turkmen government official in his car in the city centre.

In the town of Yathrib, 90 km north of Baghdad, tribes aided by ISIS fighters attacked the huge al Bakr air base, known under U.S. occupation as "Camp Anaconda", with mortars, according to a security source and the deputy head of the municipality.

Police and army forces also clashed with ISIS militants just north of the town of Udhaim in nearby Diyala province, after being driven out of the town into several villages around the Himreen mountains, a militant hideout, security sources said.

In recent days, Baghdad's grip on the Western frontier with Syria and Jordan has been challenged. One post on the Syrian border has fallen to Sunni militants and another has been taken over by the Kurds. A third crossing with Syria and the only crossing with Jordan are contested, with anti-government fighters and Baghdad both claiming control.

For ISIS, capturing the frontier is a step towards the goal of erasing the modern border altogether and building a caliphate across swathes of Iraq and Syria.

An Iraqi military spokesman said the government had carried out air strikes on a militant gathering in the town of al-Qaim near the Syrian border, which is under the control of the coalition of Sunni armed groups, including ISIS.

A hospital official in Qaim said 17 people died in the strikes and 52 were wounded, a number that was impossible to confirm independently.

Political foundation

Kerry thanked the Kurds for their "security cooperation" in recent days, and said their forces were "really critical in helping to draw a line with respect to ISIS".

Kurdistan now shares a border more than 1,000 km long with territory held by insurgents. Militants have skirmished with Kurdish peshmerga forces, but both sides have sought to avoid an all-out confrontation for now.

U.S. President Barack Obama has offered up to 300 American advisers to Iraq but held off granting a request by Maliki's government for air strikes.

The insurgency has been fuelled by a sense of persecution among many of Iraq's Sunnis, including armed tribes who once fought al Qaeda but are now battling alongside the ISIS-led revolt against Maliki's Shi'ite-led government.

Maliki's State of Law coalition won the most seats in the election in April but still needs support from rival Shi'ite factions as well as Kurds and Sunnis to keep him in power.

Some State of Law figures have suggested they could replace Maliki to build a government around a less polarising figure, although Maliki's allies say he has no plan to step aside.

His main foreign sponsors, Washington and Tehran, have both called for a swift agreement on an inclusive government, suggesting they may be ready to abandon the combative 64-year-old Shi'ite Islamist after eight years in power.