Israel bombarded targets in Lebanon and Gaza overnight in retaliation for a barrage of rockets fired from Lebanon, the most serious escalation in years along Israel’s northern border. But much of the fighting had subsided by Friday morning and all sides appeared intent on containing a cross-border conflagration.

In the Israeli-occupied West Bank, however, a new attack stirred tensions. The Israeli military said that shots had been fired on a car carrying Israelis in the Jordan Valley, and the ambulance service Magen David Adom said that two women had been killed and a third critically injured. The Israeli government said that it was treating the shooting as a “terrorist” attack, suggesting that Palestinians were suspected.

Hamas, the Palestinian militant group that dominates the Gaza Strip, praised the shooting and described it as a response to Israel’s “crimes” against Muslim worshipers at a holy site in Jerusalem and to the airstrikes on Lebanon and Gaza. But it stopped short of taking responsibility.

Frictions have steadily climbed over the course of this week, starting with an Israeli police raid in the early hours of Wednesday at the holy site, the Aqsa Mosque compound, which is known to Jews as the Temple Mount. Palestinians had barricaded themselves inside a prayer hall of a mosque ahead of an expected visit to the compound by Jewish pilgrims marking the start of Passover, which coincides this year with the Muslim fasting month of Ramadan.

In an apparent response to the police raid, militias based in southern Lebanon on Thursday fired more than 30 rockets across Israel’s northern border, causing damage to property but no fatalities. The Israeli military attributed the rocket fire from Lebanon to branches of Hamas and Palestinian Islamic Jihad, two militias based in Gaza that also have a presence in Lebanon. Both of those groups had condemned the raid at the holy site.

The military said it believed that the groups had acted with the knowledge of Hezbollah, the Iran-backed militia that dominates southern Lebanon.

Israeli warplanes retaliated before 1 a.m. on Friday with strikes on several sites in Gaza, most of them connected to Hamas’s military wing. Roughly four hours later, Israeli planes struck what the military said were three sites controlled by Hamas in southern Lebanon, close to where the rocket barrage originated on Thursday afternoon.

Experts said it was the most serious escalation along the Israel-Lebanon border since 2006, when Israel fought a monthlong war against Hezbollah. It raised fears of a wider conflict on multiple fronts between Israel, Palestinian militias and their allies.

The violence further complicated an already volatile security situation in the region. It came at a time of rising tensions in Jerusalem, unusually high violence in the occupied West Bank and divisions within the Israeli military and the broader society over a contentious plan by the Israeli government to overhaul the country’s judiciary.

“Israel’s reaction, tonight and in the future, will exact a significant price from our enemies,” Benjamin Netanyahu, the Israeli prime minister, said after his military’s warplanes hit Gaza.

The Israeli response did not immediately prompt more rocket fire from Lebanon, but it did lead armed groups in Gaza to launch 44 short-range rockets toward Israel, according to the Israeli military.

Most were intercepted by Israeli air defense systems or landed in open areas and only one hit a building, as both sides avoided causing the kind of damage that would turn the confrontation into all-out war.

The Lebanese government, which has only limited influence over Hezbollah-dominated southern Lebanon, condemned the rocket fire emanating from its territory in an apparent effort to deflect any plans for further launches and Israeli retaliation.

The militias in Gaza avoided firing rockets deep into Israeli territory — a sign that they did not seek a more drawn-out conflict. Israel also avoided targeting dense urban areas, though one strike caused collateral damage to a hospital, according to the Health Ministry in Gaza. No injuries were reported on either side.

On Friday morning, Lt. Col. Richard Hecht, a spokesman for the military, said that there had been “a lot of messaging” in diplomatic channels in an effort to defuse the situation, and that Egypt had played a main role. “Quiet will be answered with quiet,” he told reporters in a briefing, adding, “Nobody wants an escalation right now.”

After several hours of calm along the borders with Gaza and Lebanon, the Israeli military announced at about 11 a.m. that residents in those areas no longer needed to remain close to bomb shelters.

No Jewish pilgrims were expected to enter the holy site in Jerusalem on Friday, when it is generally closed to non-Muslim visitors, a factor that security officials hoped could help prevent another round of clashes.

Hiba Yazbek contributed reporting from Nazareth, Israel.