Earlier, the opposition expressed concern that the authorities were preparing to step up action against it after official media said pro-reform students had torn up a picture of Khomeini during a rally on Monday.
Khamenei said that such opposition rallies were illegal and he urged authorities to identify "those behind the insult to Imam Khomeini".
"We, as followers of Imam Khomeini, will not tolerate any shortcoming in identifying, trying and punishing those behind the insult and those who carried it out," Iran's Revolutionary Guards said in a statement.
Some reformist websites have suggested that Mir Hossein Mousavi, the opposition leader, may be arrested, six months after his election defeat by Ahmadinjad plunged Iran into turmoil.
But any detention of Mousavi, who advocated a return to Khomeini's fundamental values during his election campaign, may provoke new opposition demonstrations.
Meanwhile, Mousavi has been quoted in the past as condemning the incident relating to the picture.
Analysts say the internal crisis has further clouded prospects for any resolution of a long-running row with the West over Tehran's nuclear programme, which the United States suspects is aimed at making bombs. However, Tehran continues to deny any such claims.
Khomeini led the 1979 overthrow of the US-backed Shah and remains widely revered in Iran. He died in 1989 and was succeeded by Khamenei as supreme leader, Iran's highest authority under its government system of clerical rule.