Rights groups said protesters had chanted: "We should not mourn for our youth, we should avenge them."
"We all have a duty to deal with the enemy and its traitorous or ignorant agents," said Mr Khamenei.
In the western city of Mahabad, at least three people, including a 52-year-old woman, were killed in protests on Thursday, rights groups said.
Angry crowds had taken to the streets following the funeral of Ismail Mauludi, 35, who was killed the previous night.
Amnesty International said security forces were using firearms against "thousands" of people in Mahabad, located in West Azerbaijan province, and called on Tehran to "immediately" rein them in.
Large crowds attacked the governor's office and police stations, footage on social media showed. Demonstrations were also held in other cities throughout the province.
Her death sparked nationwide outrage and energised protesters across the political spectrum, from secular students in Tehran to regional minority groups and trade unions, who have been on strike in recent days.
Her family are being held under house arrest at their home in Iran, her cousin has confirmed to The National on Thursday.
Amini's parents and her brother have been “detained in their home” by authorities since Wednesday, Erfan Mortazei said, speaking from the Kurdish region of Iraq.
Thousands of people had gathered in Amini’s home town on Wednesday, despite a heavy security presence.
Traffic clogged roads into the city as mourners thronged a cemetery on the outskirts of the town, some making their way on foot to avoid gridlocked roads.
Anger swelled among the crowds and according to AFP, who verified a video posted online, a police checkpoint was burnt down.
Kurdistan governor Esmail Zarei-Kousha accused Iran's foes of being behind the unrest, echoing remarks by former Iranian President Hassan Rouhani, who has repeatedly blamed foreign plots for the anti-government movement.
“The enemy and its media … are trying to use the 40-day anniversary of Mahsa Amini's death as a pretext to cause new tensions but fortunately the situation in the province is completely stable,” Mr Kousha said, quoted by state news agency IRNA.
Oslo-based group Iran Human Rights said the security forces' clampdown on the Amini protests has claimed the lives of at least 141 demonstrators, in an updated death toll on Tuesday.
Amnesty International says the “unrelenting brutal crackdown” has killed at least 23 children while IHR said at least 29 children have been killed.
The continuing unrest has all but derailed talks to return to a 2015 nuclear deal between Iran and world powers, which would have resulted in crushing trade sanctions being lifted in exchange for regular UN inspections of Iran’s nuclear sites.
That now seems like a distant prospect as the US, the EU and Canada have imposed more sanctions on Iran in recent days, not only for the violent crackdown on protesters but also because Iran has been confirmed by the UN to have supplied drones to Russia, during the continuing war in Ukraine.