* Sharpest rejection by Iran of U.S. aid for mutual Iraqi ally
* ISIL militants capture second Syria-Iraq border post
* Kerry calls for
* Towns along Euphrates open supply route for militants
Ayatollah Ali Khamenei's condemnation of U.S. action in Iraq came three days after President Barack Obama offered to send 300 military advisers in response to pleas from Iraq's government. It ran counter to speculation that old enemies Washington and Tehran might cooperate to defend their mutual ally in Baghdad after two weeks of swift territorial gains by Sunni Islamists.
On Sunday, militants overran a second frontier post on the Syrian border as the Islamic State of Iraq and the Levant (ISIL) pursues the goal of its own caliphate straddling both countries.
"We are strongly opposed to U.S. and other intervention in Iraq," IRNA news agency quoted Khamenei as saying. "We don't approve of it as we believe the Iraqi government, nation and religious authorities are capable of ending the sedition."
Some Iraqi observers interpreted his remarks as a warning not to try to handpick any successor to Prime Minister Nuri al-Maliki, amid speculation he may be pushed to quit over a crisis for which many in the West hold him responsible after eight years of Shi'ite-led government has alienated minority Sunnis.
Speaking in Cairo, Secretary of State John Kerry said the United States wanted the Iraqi people to find a leadership that would represent all the country's communities - though he echoed Obama in saying it would not pick or choose those leaders.
"The United States would like the Iraqi people to find leadership that is prepared to represent all of the people of Iraq, that is prepared to be inclusive and share power," he said.
The Iranian and the U.S. governments had seemed open to collaboration against al Qaeda offshoot the Islamic State in Iraq and the Levant (ISIL), which is fighting both the U.S.-backed, Shi'ite-led government of Iraq and the Iranian-backed president of Syria, whom Washington wants to see overthrown.
"American authorities are trying to portray this as a sectarian war, but what is happening in Iraq is not a war between Shi'ites and Sunnis," said Khamenei, who has the last word in the Islamic Republic's Shi'ite clerical administration.
Accusing Washington of using Sunni Islamists and followers of ousted Iraqi leader Saddam Hussein, he added: "The U.S. is seeking an Iraq under its hegemony and ruled by its stooges."
Tehran and Washington have been shocked by the lightning offensive, spearheaded by ISIL and involving Sunni tribes and Saddam loyalists. It has seen swathes of northern and western Iraq fall, including the major city of Mosul on June 10.
ISIL thrust east from a newly captured Iraqi-Syrian border post on Sunday, taking three towns in Iraq's western Anbar province after seizing the frontier crossing near the town of Qaim on Saturday, witnesses and security sources said.
They seized a second, al-Waleed, on Sunday.
The gains have helped ISIL secure supply lines to Syria, where it has exploited the chaos of the uprising against President Bashar al-Assad to seize territory. The radical Islamist faction is considered the most powerful force among Sunni armed groups who seized Falluja, just west of Baghdad, and took parts of Anbar's capital Ramadi at the start of the year.
The fall of Qaim represented another step towards the realisation of ISIL's military goals, erasing a frontier drawn by colonial powers carving up the Ottoman empire a century ago.
ISIL's gains on Sunday included the towns of Rawa and Ana along the Euphrates river east of Qaim, as well as the town of Rutba further south on the main highway from Jordan to Baghdad.
A military intelligence official said Iraqi troops had withdrawn from Rawa and Ana after ISIL militants attacked the settlements late on Saturday. "Troops withdrew from Rawa, Ana and Rutba this morning and ISIL moved quickly to completely control these towns," the official said.
"They took Ana and Rawa this morning without a fight."
Military spokesman Major-General Qassim al-Moussawi said the withdrawal from the towns was intended to ensure "command and control" and to allow troops to regroup and retake the areas.
"The withdrawal of the units was for the purpose of reopening the areas," he told reporters in Baghdad.
The towns are on a strategic supply route between ISIL's positions in Iraq and in eastern Syria, where the group has taken a string of towns and strategic positions from rival Sunni forces fighting Assad over the past few days.
The last major Syrian town not in ISIL's hands in the region, the border town of Albukamal, is controlled by the Nusra Front, al Qaeda's branch in Syria which has clashed with ISIL but also agreed to local truces at times.
ISIL, disowned by al Qaeda in February after defying the movement's global leadership to pursue its own goals in Syria, has pushed south down the Tigris valley since capturing Mosul with barely a fight, occupying towns and taking large amounts of weaponry from the fleeing Iraqi army.
Overnight, ISIL fighters attacked the town of al-Alam, north of Tikrit, according to witnesses and police in the town. The attackers were repelled by security forces and tribal fighters, they said, adding that two ISIL fighters had been killed.
State television reported that "anti-terrorism forces" in coordination with the air force had killed 40 ISIL members and destroyed five vehicles in fighting in Tikrit, home town of Saddam Hussein, the Sunni leader ousted by U.S. forces in 2003.
There was a lull in fighting at Iraq's largest refinery, Baiji, near Tikrit, on Sunday. The site had been a battlefield since Wednesday as Sunni fighters launched an assault on the plant. Militants entered the large compound but were repelled by Iraqi military units. The fighters now surround the compound.
A black column of smoke rose from the site Sunday. Refinery officials said it was caused by a controlled burning of waste.
The ISIL advance has been joined by Sunni tribal militias, other Islamist groups that were active during the U.S. military occupation of 2003-11, and former members of Saddam's Baath Party. All are united in their hatred of Maliki and Shi'ite politicians brought to power in U.S.-backed elections.
Relations between the diverse Sunni groups have not been entirely smooth. On Sunday morning, clashes raged for a third day between ISIL and Sunni tribes backed by the Naqshbandi Army, a group led by former army officers and Baathists, around Hawija, local security sources and tribal leaders said.
More than 10 people were killed in the clashes in the area, southwest of the northern oil hub of Kirkuk, the sources said.
On Friday evening, ISIL and Naqshbandi fighters began fighting each other in Hawija, where a crackdown on a Sunni protest over a year ago triggered unrest leading to the current insurgency. Iraqi and Western officials believe that as ISIL and other Sunni factions start to consolidate their control of newly won territories, they may start turning on each other.
U.S. President Barack Obama has offered up to 300 U.S. special forces advisers to help the Iraqi government recapture territory but has held off granting a request for air strikes.
The fighting has threatened to tear the country apart for good, reducing Iraq to separate Sunni, Shi'ite and ethnic Kurdish regions. It has highlighted divisions among regional powers, especially Iran, which has said it would not hesitate to protect Shi'ite shrines in Iraq if asked, and Sunni Saudi Arabia, which has warned Iran to stay out of Iraq.
Iraq's Kurds have meanwhile expanded their territory in the northeast, including the long-prized oil city of Kirkuk.
The government has mobilised Shi'ite militias and regular citizens to fight on the frontlines and defend the capital - thousands of fighters in military fatigues marched in a Shi'ite slum of the capital Baghdad on Saturday.