Iran's supreme leader Ayatollah Ali Khamenei said Tuesday that Armenian-held territory in Azerbaijan "must be returned" and warned the conflict in Nagorno-Karabakh was threatening regional security.
Hundreds of people have been killed since new fighting erupted in late September over the disputed Karabakh region, which broke from Azerbaijan's control during a war in the 1990s.
Iran borders both Armenia and Azerbaijan, and Tehran has deployed troops along its frontiers following stray fire from the fighting.
"Territories seized by Armenia must be returned and liberated. This is an essential condition," Khamenei said in a televised address. "These lands belong to Azerbaijan, which has every right over them."
Khamenei added that "the security of Armenians who live in these lands must be ensured", urging the warring parties to respect international borders.
"This war... threatens the security of the region," he said. "It must end as soon as possible."
Iran has good relations with both countries and has repeatedly called on the two sides to cease hostilities. Tehran has also offered to facilitate talks.
Khamenei's comments went a step further than those of President Hassan Rouhani, who had said last month that "occupation is in no case acceptable", without explicitly naming Armenia.
"Everyone" must "accept the reality... and respect other countries' territorial integrity", Rouhani had said.
According to some estimates, Azeris make up 10 million of the 80-million population of Iran, which is also home to almost 100,000 Armenians.
Khamenei also warned Tuesday that "terrorists must not set up in proximity to our borders", echoing Rouhani's earlier comments.
"The presence of such terrorists has been highlighted by trustworthy information," Khamenei said.
"If we feel a threat from them, we will react firmly and unequivocally."
Rouhani last month warned Iran would not tolerate "terrorists" near its border with Azerbaijan, after France and Russia raised the alarm over the deployment of militants from Syria to the Karabakh conflict.