He said: "The first step to resolve insecurity in Iraq is the withdrawal of the occupiers and handing over the security issues to the Iraqi government."
He also told Jalal Talabani: "US agents in the region are the middle men for implementing American policies and creating an insecure Iraq."
The US, however, has said that fighting in Iraq has been fuelled by Iranian weapons exports and its backing for Shia muslim groups.
Khamenei said: "Supporting terrorist groups in Iraq and igniting insecurity ... will be very dangerous for America's agents and also the region."
Güncelleme Tarihi: 20 Eylül 2018, 18:16
Iraq "close to civil war"
Iraqis fear a new wave of sectarian blood-letting after a bombing on Thursday killed 202 people, the worst such attack since the US-led invasion in 2003.
Kofi Annan, the UN secretary general, said Iraq had been pushed closer to civil war and called for Iran and Syria to help.
"Iran will do its utmost to help establish security in Iraq," said Khamenei, adding that Iran wanted a secure and developed neighbour.
Talabani has said that Iraq wants Iran's assistance.
Washington is facing growing calls to enter a dialogue with Iran to help end the violence.
The White House said the issue of talking to Iran and Syria about Iraq was likely to be raised at a meeting this week between George W Bush, the US president and Nuri al-Maliki, the Iraqi prime minister.
Bush said on Tuesday that conditions for the US to hold direct talks with Tehran had not changed. Washington still accuses Iran of seeking to develop nuclear weapons.
President Bush said during a press conference in Estonia: "As far as the United States goes, Iran knows how to get to the table with us, which is to do that which they said they would do, which is verifiably suspend their enrichment programme."
The US and other Western powers insist that Iran must suspend sensitive atomic work before negotiations start over a package of economic and political incentives offered by six world powers as a reward for such a move.
Iran has refused to stop and insists it does not seek atomic bombs but only wants nuclear technology to make electricity.