Outside powers have often exploited ethnic and religious divisions in Muslim states and "they dream of a war between Shi'ites and Sunnis" that would not happen, he said in Tehran, according to an official statement.
He warned against what he called Western propaganda about "a cast of morons and Saddam Hussein leftovers," apparent references to the radical Sunni Islamic State in Iraq and the Levant (ISIS) group and Sunni tribes who once sided with the country's deposed dictator and now fight with ISIS.
"The incident in Iraq is not a war between Shi'ites and Sunnis," Khamenei said at a meeting with families of victims of a 1981 bombing that destroyed the Tehran headquarters of the ruling Islamic Republic Party in 1981.
"It is a battle between supporters and opponents of terrorism, it's a war between fans of America and the West and those favouring independence for their nation," he said of the Iraq violence. "It's a showdown between humanity and barbarian savagery."
ISIS Sunni militants have seized a broad swath of territory in northern and western Iraq in recent weeks in their quest to topple the government of Prime Minister Nuri al-Maliki, a Shi'ite, and set up a classic Islamic caliphate.
Deeming Shi'ites to be heretics, ISIS militants have posted videos showing executions of government troops upon capture. Iranian media are rife with reports of other atrocities allegedly committed by ISIS.
Disgruntled Iraqi Sunnis accuse Maliki of excluding them from power, which has prompted some Sunni tribes and former Saddam loyalists to join ISIS's armed rebellion.
Iran is a close ally of Maliki and its official reaction has been guarded as the ruling clergy sought to play down the idea of a showdown between Shi'ites and Sunnis, who make up the overwhelming majority in the Muslim world.
In his speech, Khamenei characterised the events in Iraq and elsewhere in the Middle East as a Western conspiracy.
Last week, Khamenei said he opposed intervention in Iraq by the United States or any other country to stop ISIS. President Barack Obama has said he would not send ground forces back to Iraq, limiting assistance to military advisers, intelligence and surveillance operations.