TEHRAN, Iran — Iran's President Hassan Rouhani on Wednesday warned that his country will not tolerate the presence of foreign fighters — "terrorists that Iran has fought for years" — near its northern border, where a conflict is raging between Azerbaijan and Armenia.

Rouhani did not elaborate but Armenia accuses Ankara of sending Turkish-backed Syrian fighters to the self-proclaimed Republic of Nagorno-Karabakh in Azerbaijan. In Syria's civil war, Iran, an ally of Syrian President Bashar Assad, is on the opposite side of Ankara, which supports Syrian opposition fighters.

Heavy fighting between Azerbaijani and Armenian forces in the Nagorno-Karabakh region since Sept. 27 has killed scores of both servicemen and civilians. Nagorno-Karabakh lies inside Azerbaijan but has been under the control of ethnic Armenian forces backed by Armenia since 1994, when a truce ended a war that raged for several years and killed an estimated 30,000 people on both sides.

The fighting, involving heavy artillery, warplanes and drones has continued despite numerous international calls for a cease-fire.

"Iran will not allow anyone, on some pretext, to bring terrorists that Iran has fought for years to our border," Rouhani told a Cabinet meeting on Wednesday.

"It is not acceptable, and we have clearly told this to officials of neighboring nations," he said, according to the presidential website. Rouhani did not elaborate.

The remarks were Rouhani's first on the issue of foreign fighters sent to the volatile region. Armenia alleges that Turkey, a key supporter of Azerbaijan, is sending mercenaries from Syria to the region — a charge that Ankara denies. The Britain-based monitoring group that tracks Syria's civil war — known as the Syrian Observatory for Human Rights — has reported that as many as 850 Syrian fighters have arrived in Azerbaijan.

Rouhani also warned that the conflict between Azerbaijan and Armenia may escalate into a "regional war," which would "not be in the interest of any country." He referred to Azerbaijan as a brother nation and called Armenia a neighbor and urged for peace.

"We have very good relations with both nations," Rouhani said. "The war should come to the end. We hope stability returns to the region."

He stressed that the security of Iran's border area is "very important" and that in talks with officials from both Azerbaijan and Armenia, Iran has insisted on restoring security.

Iran has occasionally complained that stray mortar shells from the Nagorno-Karabakh fighting have struck Iranian border villages and towns. There have been no Iranian fatalities so far, though a six-year old child was reported wounded and some buildings were damaged.

On Monday, Iran's foreign ministry said it's working on a peace plan to end the fighting between Armenia and Azerbaijan and warned against the conflict spilling across Iran's border — "a very serious red line for the Islamic Republic that should not be crossed."

Iran shares nearly 760 kilometers (470 miles) of its border with Azerbaijan and about 35 kilometers (22 miles) with Armenia, with traditionally good relations with both neighbors, though public opinion in the predominantly Shiite Iran mainly supports Azerbaijan.