JERUSALEM — Israel has flexed its military muscles in recent months as the regional balance of power has pitched further in favor of its most bitter adversaries: Iran and its Lebanese proxy Hezbollah.

Analysts and former senior Israeli military officers say Israel is showing that it will act with force to protect its interests, while using just enough of it to limit its enemies without sparking a war. But it's a precarious line to tread, and even a small misstep could lead to conflict, they say.

Israel is scrambling to adjust as Syrian President Bashar Assad has taken the upper hand in his country's six-year war, propped up by an emboldened Iran and an array of Shiite militias, including Hezbollah, which has sent thousands of fighters to back him.

The Israeli government had expressed frustration as the Trump administration focused on fighting Islamic State militants without, in Israel's opinion, sufficiently limiting Iran and its proxies. Israeli Prime Minister Benjamin Netanyahu publicly criticized a U.S.-Russia cease-fire deal in southern Syria for not including provisions to stop Iranian expansion.

Israel is now making itself heard. Last week Israeli jets buzzed so low over southern Lebanon that they shattered windows and caused panic. That followed the bombing of a military site in Syria earlier in the month that had been linked to missile production for Hezbollah.

On Tuesday, the army used a Patriot missile to shoot down a drone that neared its airspace.

Threats have escalated on both sides. "If the Zionist regime makes any wrong move, Haifa and Tel Aviv will be razed," Iran's army chief Maj. Gen. Abdolrahim Mousavi warned this week in comments published by Fars news agency, referring to Israeli cities within the range of Hezbollah rockets.

Hezbollah and Israel fought a month-long war in 2006 that caused heavy casualties, and both sides claimed victory. Since then, the Syrian war has provided Hezbollah fighters with a training opportunity, while Israel estimates that it has built up a stockpile of more than 100,000 rockets.

Israel fears Iran will help Hezbollah upgrade to more accurate precision-guided missiles and establish a permanent military presence in Syria, from where they could eventually turn their focus south.

"Generally speaking, this is the kind of threat we can't live with," said Brig. Gen. Nitzan Nuriel, a former Israeli Defense Forces officer who was deputy commander of the division responsible for the Lebanese front during the 2006 war. "This is the kind of threat we need to deal with."

In recent months, Netanyahu has accused Iran of establishing long-range missile-manufacturing sites in both Lebanon and Syria. Satellite images showing one alleged site, near the port city of Baniyas, were shared with the press.

Israel is keen to leverage more favorable outcomes in Syrian cease-fire deals where it feels its interests have been ignored, and public threats and messages are meant as much for Israel's allies as its enemies, Nuriel said.

"At the same time we will try to keep Hezbollah weak to remind them what happened in 2006," he said.

After speaking out against the "de-escalation" deal for southern Syria reached by the United States and Russia on the sidelines of the G-20 summit, Netanyahu traveled to Sochi to meet with Russian President Vladimir Putin. A high-level delegation was also dispatched to Washington.

Russia's foreign minister Sergey Lavrov later made a public assurance that Israel's security interests in southern Syria were being taken into account.

In a speech last month, Hezbollah Secretary General Hasan Nasrallah mocked Netanyahu for "crying" over the defeat of Islamic State in Iraq and Syria.

Nasrallah has repeatedly warned Israel against attacking Lebanon.

"If the Israelis think they can now make war in Lebanon, then they are making a big mistake. In Syria we have learned to attack," said a senior official from the military alliance of Hezbollah, Syria and Iran. He spoke on the condition of anonymity because he is not authorized to speak with the press.

"The rhetoric on both sides is a substitute for action - a way of reinforcing deterrence without having to take military action - and a way of saving face," said Faysal Itani, a fellow at the Washington-based Atlantic Council. "But I do think things are trending negatively."

Netanyahu tried to drive his point home at the U.N. General Assembly in New York on Tuesday, saying that "those who threaten us with annihilation put themselves in mortal peril." Israel will act to prevent Iran from opening "new terror fronts" on Israel's northern border, he said.

He also pushed for changes to the international deal limiting Iran's nuclear activities.

"This is all classic Netanyahu," said Ofer Zalzberg, a senior analyst at International Crisis Group. "Saying 'hold me back before I do something,' but I don't see Israel launching a preemptive war. The next war between Israel and Hezbollah will be dramatic for Israel's population and will have consequences for whoever is in power."

But the prospect is not impossible; there are some Israeli officials advocating intervention, he said, describing Israel as "panicked." "Advocates are saying bomb now."

They see a window of opportunity. While Syria has restrained from retaliating against Israeli strikes on its soil, that is likely to change as the war draws to an end, raising the stakes of the occasional intervention with airstrikes that Israel is currently engaged in.

In Lebanon, Hezbollah's growing strength has come at a cost, one that could cause personnel problems in the event of renewed conflict.

The group does not publish figures for the number of their members who have fought and died in Syria, but more than 1,000 have been killed according to one study of Arabic language press coverage of funerals in Lebanon.

On a recent day in the Beirut suburb of Dahiyeh, a steady trickle of relatives passed through a newly opened cemetery for fighters recently killed in Syria. Marble slabs are adorned with photographs of the men in fatigues, some decorated with roses for Father's Day.

Sitting quietly at the gravestone of a commander killed last year, a woman named Rukiya said her son died in the battle to recapture the northern city of Aleppo. "He knew he didn't have to go, but he didn't listen to me," she said. "The resistance was everything to him."

But during the war, Hezbollah has also gained experience. The Israeli military now fears a scenario in which Hezbollah, which formed in the 1980s to fight the Israeli occupation of Lebanon, could raid one of Israel's 22 border communities as war in Syria winds down.

In April, Hezbollah organized a rare press trip to the area to highlight what appeared to be newly constructed fortifications on the Israeli side of the U.N.-patrolled buffer zone between the two countries.

"The Israeli enemy is undertaking these fortifications and building these obstacles in fear of an advance," said a Hezbollah commander who went by the nom de guerre Haj Ihab.

Israel's Defense Ministry confirmed that it was indeed bolstering its defenses, including walls near Israel's northern communities that are vulnerable to cross-border sniper fire or antitank missiles, Israeli media reported. It also said the project will cost some $34.7 million.

"We are strengthening the border based on the understanding that in any future conflict, Hezbollah would make a concerted effort to cross the border," said an Israeli Defense Forces official in the Northern Command who spoke on the condition of anonymity because he was not authorized to speak publicly.

In the meantime, Israel will continue its strategy of "deterrence and prevention," Nuriel said, managing the risks of escalation.

"You need to ask yourself, if you do this, what will the enemy do?" he said. "Many times we decide taking action is better."

But Israel's 2006 war with Hezbollah began when militants launched a cross-border raid on an Israeli patrol, killing three Israeli soldiers and abducting two. Nasrallah later said that if he'd known how Israel would react, Hezbollah would not have carried out the raid. The war left 1,000 Lebanese and nearly 160 Israelis dead. Now the stakes are higher.

"Syria made the machine faster," said Kamal Wazne, a professor at the American University of Beirut who studies the group. "A confrontation is going to be deadly, destructive and painful for both sides."