* Mortars hit "Camp Anaconda"
* 40 U.S. special operations personnel in Iraq
* Government troops battle fighters for control of refinery
By Raheem Salman
BAGHDAD, June 25 (Reuters) - Militants attacked one of Iraq's largest air bases on Wednesday as the first U.S. teams arrived to assess the Iraqi security forces and decide how to help counter a mounting Sunni insurgency.
Two weeks of advances by militants spearheaded by al Qaeda offshoot the Islamic State in Iraq and the Levant (ISIL) has threatened to rupture the country two and a half years after the withdrawal of U.S. troops.
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 the onslaught.
Militants including ISIL and allied Sunni tribes battled Iraqi forces in the town of Yathrib, 90 km north of Baghdad, into the early hours of Wednesday, witnesses and the deputy head of the municipality said. Four militants were killed, they said.
Insurgents have surrounded a massive air base nearby, which was known as "Camp Anaconda" under U.S. occupation, and struck it with mortars. Eyewitnesses said the air base had been surrounded on three sides.
More than 1,000 people, mainly civilians, have been killed in less than three weeks, the United Nations has said, calling the figure "very much a minimum".
The figure includes unarmed government troops machine gunned in mass graves by insurgents, as well as several reported incidents of prisoners killed in their cells by retreating government forces.
U.S. President Barack Obama has offered up to 300 American advisers to Iraq but held off granting a request by Prime Minister Nuri al-Maliki's government for air strikes.
Rear Admiral John Kirby, the Pentagon press secretary, said late on Tuesday 130 of the advisers had now been deployed, with the initial group sent to establish the operations centre included intelligence analysts, logistics experts and special operations forces.
Kirby said about 40 special operations personnel already in the country and assigned to the U.S. Embassy's Office of Security Cooperation had been deployed as part of the first two assessment teams.
About 90 additional troops arrived in Iraq to begin helping establish a Joint Operations Center in Baghdad with Iraqi forces. Another 50 U.S. military personnel working in the region are expected to arrive within the next few days to create four additional assessment teams, Kirby said.
U.S. military personnel also are flying regular manned and unmanned reconnaissance flights over Iraq - about 30 to 35 per day - to give better insight about the situation on the ground and help the assessment teams, he said.
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 Wednesday. State TV showed troop reinforcements flying into the compound by helicopter to fend 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 government official said Baghdad wanted the tribes to break with ISIL 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 recent days, Baghdad's grip on the Western frontier with Syria and Jordan has also 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 ISIL, 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 on Tuesday 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 ISIL.
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 ISIL-led advance. (Additional reporting by a reporter in Diyala and David Alexander in Washington; Writing by Alexander Dziadosz; editing by Anna Willard)
Our Standards: The Thomson Reuters Trust Principles.