* Kerry says Washington considering cooperation with Tehran
* ISIL fighters capture northwestern town of Tal Afar
* ISIL advance has halted north of Baghdad
* Shi'ite volunteers rally to defend state
Militants from the Islamic State of Iraq and the Levant have routed Baghdad's army and seized the north of the country in the past week, threatening to dismember Iraq and unleash all-out sectarian warfare with no regard for national borders.
The fighters have been joined by other armed Sunni groups who oppose what they say is oppression by Prime Minister Nuri al-Maliki, a Shi'ite.
Joint action between the United States and regional Shi'ite power Iran to help prop up their mutual ally in Baghdad would be unprecedented since Iran's 1979 revolution, demonstrating the urgency of the alarm raised by the lightning insurgent advance.
U.S. Secretary of State John Kerry called the advance an "existential threat" for Iraq. Asked if the United States could cooperate with Tehran against the insurgents, Kerry told Yahoo News: "I wouldn't rule out anything that would be constructive."
As for air strikes: "They're not the whole answer, but they may well be one of the options that are important," he said. "When you have people murdering, assassinating in these mass massacres, you have to stop that. And you do what you need to do if you need to try to stop it from the air or otherwise."
The Pentagon said that while there might be discussions with Iran, there were no plans to coordinate military action with it.
Britain, Washington's ally in the 2003 war that deposed Sunni dictator Saddam Hussein, said it had reached out to Iran in recent days. A U.S. official said meetings with Iran could come this week on the sidelines of international nuclear talks.
Iran has longstanding ties to Maliki and other Shi'ite politicians who came to power in U.S.-backed elections.
ISIL seeks a caliphate ruled on mediaeval Sunni Muslim precepts in Iraq and Syria, fighting against both Iraq's Maliki and Syria's Bashar al-Assad, another ally of Iran. It considers Shi'ites heretics deserving death and has boasted of massacring hundreds of Iraqi troops who surrendered to it last week.
Its uprising has been joined by tribal groups and figures from Saddam's era who believe Maliki is hostile to Sunnis.
ISIL fighters and allied Sunni tribesmen overran yet another town on Monday, Saqlawiya west of Baghdad, where they captured six Humvees and two tanks, adding to an arsenal of U.S.-provided armour they have seized from the disintegrating army.
Eyewitnesses said Iraqi army helicopters were hovering over the town to try to provide cover for retreating troops.
"It was a crazy battle and dozens were killed from both sides. It is impossible to reach the town and evacuate the bodies," said a medical source at a hospital in the nearby city of Falluja, largely held by insurgents since early this year.
Overnight, the fighters captured the mainly ethnic Turkmen city of Tal Afar in northwestern Iraq after heavy fighting on Sunday, solidifying their grip on the north.
"Severe fighting took place, and many people were killed. Shi'ite families have fled to the west and Sunni families have fled to the east," said a city official.
Tal Afar is a short drive west from Mosul, the north's main city, which ISIL seized last week at the start of its push. Fighters then swept through towns and cities on the Tigris before halting about an hour's drive north of Baghdad.
Iraq's army is holding out in Samarra, a Tigris city that is home to a Shi'ite shrine. A convoy travelling to reinforce the troops there was ambushed late on Sunday by Sunni fighters near the town of Ishaqi. Fighting continued through Monday morning.
An Iraqi army spokesman in Baghdad reported fighting also to the south of Baghdad. He said 56 of the enemy had been killed over the previous 24 hours in various engagements.
OBAMA WEIGHING OPTIONS
President Barack Obama pulled out all U.S. troops in late 2011 and rules out sending them back, although he is weighing other options such as air strikes. A U.S. aircraft carrier has sailed into the Gulf along with a warship carrying 550 marines.
The only U.S. military contingent on the ground is the security staff at the U.S. embassy. Washington said on Sunday it was evacuating some diplomatic staff and sending about 100 extra marines and other personnel to help safeguard the facilities.
The sprawling fortified compound on the banks of the Tigris is the largest and most expensive diplomatic mission ever built, a vestige of the days when 170,000 U.S. troops fought to put down a sectarian civil war that followed the 2003 invasion.
Iraqis now face the prospect of a replay of that extreme violence, but this time without American forces to intervene.
Potential cooperation between the United States and Iran shows how dramatically the ISIL advance has redrawn the map of Middle East alliances in a matter of days.
Iran's President Hassan Rouhani, a relative moderate elected last year, has presided over a gradual thaw with the West, including secret talks with Washington that led to a preliminary deal to curb Iran's nuclear programme. But open cooperation against a mutual threat would be unprecedented.
A spokesman for British Prime Minister David Cameron confirmed that London had already made overtures to Tehran in recent days. A U.S. official said talks over Iraq between U.S. and Iranian officials could take place this week in Vienna, where both sides are attending nuclear negotiations.
Any rapprochement between Washington and Tehran over Iraq could anger U.S. allies Israel and the Sunni Gulf Arab states. Saudi Arabia, the Gulf's main Sunni power, said it rejected foreign interference in Iraq, and blamed Baghdad's "sectarian and exclusionary policies" for fuelling the insurgency.
ISIL fighters' sweep through the Tigris valley north of Baghdad included Saddam's hometown Tikrit, where they captured and apparently massacred troops stationed at Speicher air base, once one of the main U.S. troop headquarters.
A series of pictures distributed on a purported ISIL Twitter account appeared to show gunmen from the Islamist group shooting dozens of men, unarmed and lying prone. Captions said they were army deserters captured as they tried to flee fighting. They were shown being transported in the backs of trucks, led to an open field, laid down in rows and shot by several masked gunmen. In several pictures, the black ISIL flag can be seen.
"This is the fate of the Shi'ites which Nuri brought to fight the Sunnis," a caption to one of the pictures reads.
ISIL said it executed 1,700 soldiers out of 2,500 it had captured in Tikrit. Although those numbers appear exaggerated, the total could still be in the hundreds. A former local official in Tikrit told Reuters ISIL had captured 450-500 troops at Speicher and another 100 elsewhere in Tikrit. Some 200 troops were still believed to be holding out in Speicher.
Washington has urged Maliki to reach out to Sunnis to create unity, but the prime minister has spoken more of retaliation than reconciliation. He was shown on television on Monday meeting military chiefs, vowing to crush the uprising and root out politicians and officers he blamed for betraying Mosul.
"We will work on purging Iraq of the traitors, politicians and those military men who were carrying out their orders," he said. "Betrayal and treason have made us more determined and strong, and I swear a sea of men will march to put an end to this black page in Iraq's history."
Shi'ites, who form the majority in Iraq based mainly in the south, have rallied to defend the country, turning out in their thousands to join militia and the security forces after a mobilisation call by the top Shi'ite cleric, Ali al-Sistani.
A leading Sunni cleric, Rifa al-Rifaie, said Sistani's call amounted to sectarianism. Sistani is known as a moderate who never called his followers to arms during the U.S. occupation.
"Sistani, that lion, where was he when the Americans occupied Iraq?" Rifaie said. He gave a list of Sunni grievances: "We have been treated unjustly, we have been attacked, our blood had been shed and our women have been raped."
ISIL emerged after Saddam's fall, fought against the U.S. occupation as al Qaeda's Iraq branch and broke away from al Qaeda after joining the civil war in Syria. It says the movement founded by Osama bin Laden is no longer radical enough.
Its cause has also been taken up by many other Sunni groups who share its view that Maliki's government oppresses them.
Tareq al-Hashemi, a Sunni who was vice president until fleeing the country in 2012 after Maliki accused him of terrorism, said Maliki must go: "What happened is an uprising by the Sunni Arabs in Iraq to confront oppression and marginalisation," Hashemi told the BBC. "Resolving the conflict in Iraq comes through excluding Maliki from power."