"The Americans should know that if they start a war, this time it will be a regional war," Khamenei was quoted as saying by Tasnim.
The comments from the 86-year-old are the most-direct threat he's made so far.
Iranian state television added Khamenei said: "We are not the instigators and we do not seek to attack any country. But the Iranian nation will deliver a firm blow to anyone who attacks or harasses it."
He also compared the nationwide protests that challenged Iran's theocracy to "a coup."
The comments come as tens of thousands of people are reportedly detained in Iran after the protests.
Seditious charges in Iran can also carry the death penalty, which again renews concerns about Tehran carrying out mass executions for those arrested.
Iran's conducting mass executions had been one of the red lines laid down by US President Donald Trump for potentially using military force against the country.
Earlier, top Iranian security official Ali Larijani said work on a framework for negotiations with the United States was progressing.
"Contrary to the atmosphere being created by artificial media warfare, the formation of a structure for #negotiations is under way," Larijani wrote, without giving further details.
Trump said on January 22 an "armada" was heading toward Iran.
Multiple sources said on Friday that Trump was weighing options against Iran that include targeted strikes on security forces.
Trump told Fox News correspondent Jacqui Heinrich that Iran was "negotiating, so we'll see what happens," Heinrich wrote on X.
"You know, the last time they negotiated, we had to take out their nuclear, didn't work, you know. Then we took it out a different way, and we'll see what happens," Heinrich quoted Trump as saying.
Iranian President Masoud Pezeshkian on Saturday accused US, Israeli and European leaders of exploiting Iran's economic problems, inciting unrest and providing people with the means to "tear the nation apart".
Iran has been rocked by protests that erupted in December over economic hardship and have posed one of the toughest challenges to the country's clerical rulers.
with DPA and AP