* Visit comes after militant gains on the border
* Iran say U.S. trying to regain control of Iraq
* Kerry wants to forge an inclusive government - state department
By Lesley Wroughton
BAGHDAD, June 23 (Reuters) - U.S. Secretary of State John Kerry landed in Baghdad on Monday to press Prime Minister Nuri al-Maliki to form a more inclusive government in response to a Sunni insurgency that has swept much of northern and western Iraq.
Kerry's visit came after Sunni militants took strongholds along Iraq's western border at the weekend, strengthening supply routes from Syria where they have exploited a three-year-old rebellion to capture swathes of territory.
Iran's Supreme Leader Ayatollah Ali Khamenei on Sunday accused Washington of trying to regain control of the country it once occupied - a charge Kerry denied, saying the United States was committed to helping Iraq but wanted a more inclusive government.
Kerry would "discuss U.S. actions underway to assist Iraq as it confronts this threat and urge Iraqi leaders to move forward as quickly as possible with its government formation process to forge a government that represents the interests of Iraqis," State Department spokeswoman Jen Psaki said.
Washington, which withdrew its troops from Iraq in 2011 after an eight year occupation that followed the 2003 invasion that toppled dictator Saddam Hussein, has been struggling help Iraq contain a Sunni insurgency led by an al Qaeda offshoot, the Islamic State in Iraq and the Levant.
U.S. President Barack Obama agreed last week to send up to 300 special forces troops as advisers, but has held off from providing air strikes and ruled out redeploying ground troops.
Washington is worried that Maliki's Shi'ite-led government has worsened the insurgency by alienating moderate Sunnis who once fought al Qaeda but have now joined the ISIL revolt.
Kerry said on Sunday the United States would not pick or choose who rules in Baghdad. He said, however, Washington had noted the dissatisfaction among Kurds, Sunnis and some Shi'ites with Maliki's leadership and emphasised that the United States wanted Iraqis to "find a leadership that was prepared to be inclusive and share power".
Iraqis are due to form a new government after an election in April in which Maliki's list won the most seats in parliament but would still require allies to win a majority.
U.S. officials have conveyed that they are open to Maliki leaving. Senior Iraqi politicians, including at least one member of Maliki's own ruling list, have told Reuters that this message has been delivered in diplomatic language to Iraqi leaders.
Recent meetings between Maliki and the Americans have been described as tense. According to a Western diplomat briefed on the conversations by someone attending the meetings, U.S. diplomats have informed Maliki he should accept leaving if he cannot gather a majority in parliament for a third term. U.S. officials have contested that such a message was delivered.
A close ally of Maliki has described him as having grown bitter toward the Americans in recent days over their failure to provide strong military support in the face of the militant advance.
On Sunday, militants overran a second frontier post on the Syrian border, extending two weeks of swift territorial gains as ISIL pursues the goal of a caliphate straddling both countries that has raised alarm across the Middle East and in the West.
The need to battle the Sunni insurgency has put the United States on the same side as its enemy of 35 years, Iran, which has close ties to the Shi'ite parties that came to power in Baghdad after U.S. forces toppled Saddam. However, Khamenei's comments made clear that a rapprochement would not be easy.
"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 in Baghdad interpreted Khamenei's comments as a warning to the United States to stay out of the process of selecting any successor to Maliki.
Baghdad is Kerry's third stop in a tour of Middle East capitals to emphasize the threat the insurgency poses to the region and call on Iraq's allies to use their influence to press Baghdad to govern more inclusively. He has also been warning Iraq's neighbours they need to step up efforts to cut off cross-border funding to the militants. (Writing by Oliver Holmes; Editing by Peter Graff)