TEL AVIV—Israel intends to punish Tehran for the drone and missile barrage that represented Iran’s first-ever direct attack on its territory, Israeli officials said, but it faces a difficult challenge of finding a way of doing so that avoids further escalation, preserves the partnership that helped fend off the assault and doesn’t derail its war aims in Gaza.

Israel’s war cabinet met Monday to discuss how and when to respond to Iran’s attack, which Tehran said was in response to the killing by Israel of a senior Iranian general at an Iranian diplomatic building in Damascus, Syria. Israel hasn’t confirmed or denied involvement.

“We are looking ahead and considering our steps. The launching of so many missiles, cruise missiles and drones into Israeli territory will be met with a response,” said the head of Israel’s military, Herzi Halevi, during a visit to an Israeli air force base that was damaged by the Iranian attack.

Israel faces an increasingly delicate set of political calculations. It is already fighting on three fronts: in Gaza against Hamas, on its northern border with Hezbollah, as well as trying to quell unrest in the West Bank. Now, it is under pressure to restore deterrence with Iran, amid calls from allies to exercise restraint. Decision makers must balance the need to project strength with their desire to hold together a tenuous strategic partnership against Iran that helped it block the attack in the first place.

“The point is to respond smartly, in a way that won’t undermine the opportunity for regional and international cooperation that we created,” said Michael Oren, a former Israeli ambassador to the U.S.

President Biden has urged Israel to use caution in any response to Iran’s attack and pressed allies Sunday for a united diplomatic front in a bid to stop the hostilities from spiraling into open warfare that could engulf the Middle East and entangle the U.S.

“Together with our partners, we defeated that attack,” Biden said Monday while meeting with Iraqi Prime Minister Mohammed al-Sudani. Biden said the U.S. was “committed to Israel’s security. We’re committed to a cease-fire that will bring the hostages home and prevent the conflict from spreading beyond where it already has.”

Saturday’s attack demonstrated the importance of Israel’s relationship with the U.S. Analysts said that will likely be a key consideration as Israel weighs its next move and seeks to capitalize on the show of international support the assault triggered. In the weeks before Iran’s attack, Israel had faced weeks of criticism over the mounting death toll in Gaza and failure to agree to a cease-fire.

Israel’s strained relationship with the Biden administration also might be playing into Iran’s thinking, said Sanam Vakil, a Middle East expert at the U.K.’s Chatham House think tank. “I think the Islamic Republic has decided that if Israel and Iran are going into an escalatory cycle, it’s better to do it now, during the Biden administration,” she said.

The head of Iran’s Islamic Revolutionary Guard Corps, Maj. Gen. Hossein Salami, said Sunday that Iran would respond to future Israeli attacks on Iran-linked targets from Iranian soil, potentially opening the door for escalatory responses from Israel. “We have decided to create a new equation and it goes this way: from now on if the Zionist regime anywhere attacks our interests, assets, figures and citizens, we will reciprocally attack it from the origin of Iran,” Salami told a state-run television station.

Operations in Gaza are also part of the Israeli calculus, including a planned offensive in the crowded southern city of Rafah, which Israel sees as crucial to eliminating Hamas but that is opposed by Israel’s close allies and Arab neighbors who came to its defense on Saturday. The issue of a ground operation in Rafah, where more than a million Palestinians are sheltering, has been a key source of tension between Israel and the U.S. Israeli strikes on Rafah continued in recent days, even up to the moment the Iranian attack began late Saturday night, people living in the city said.

Militarily, analysts said, Israel’s decisions regarding Iran and Gaza may not be linked, but they are connected politically.

Israeli Prime Minister Benjamin Netanyahu’s right-wing base is already disgruntled that the ground operation in Rafah hasn’t taken place and doesn’t seem imminent, since Israel has pulled most of its soldiers out of Gaza. Israel is calling up two reserve brigades in the coming days for reinforcement in Gaza but will need more forces for any major operation. Now, Netanyahu’s supporters want a strong retaliation against Iran as well.

“To create deterrence in the Middle East,” Israel “has to go crazy,” Itamar Ben-Gvir, Israel’s national security minister and a voice of Israel’s hard right, said on Sunday.

Failure to act against Iran or in Rafah could further harm Netanyahu’s already diminished political support, said Chuck Freilich, a former Israeli deputy national security adviser.

“Even if he wants to show restraint on both fronts, he has to balance that,” Freilich said.

At the same time, said Freilich, Israel has an opportunity to turn the strategic partnership that helped Israel counter Iran’s offensive into something more permanent. But, he said, that would require Netanyahu to signal openness to the Biden administration’s postwar plan to combine Israel’s agreement on a path toward the establishment of a Palestinian state with Israel-Saudi normalization talks.

“It depends first and foremost on whether the prime minister is willing to say some even limited meager yes to the Biden plan for the postwar stage in Gaza,” Freilich said.

Israeli security analysts said Israel has a range of options that it would consider as retaliation rather than major escalation, without overstretching its forces that are deployed in Gaza, on its northern border and in the West Bank. In the latest confrontation on the northern border, four Israeli soldiers were injured by an explosive Sunday night while operating dozens of yards inside Lebanese territory, according to Israeli Army Radio.

Israel’s options for retaliation against Iran include cyberattacks and targeted attacks on key state-owned sites such as Iranian oil infrastructure. Israel has in the past targeted Iranian personnel and infrastructure related to Iran’s nuclear program without taking responsibility and could do so again but more overtly, analysts said. In addition to direct strikes on Iran, analysts said Israel could respond indirectly by hitting one of Iran’s proxies in the region.

Analysts said any Israeli strike on major Iranian nuclear sites would be unlikely, since they are deep underground and doing so would require the backing and aid of Washington. The U.S. has never greenlighted an Israeli counterattack, said Oren, the former Israeli ambassador, who is also a historian. “It’s when we move from defense to counter-offense, we hemorrhage American support,” he added.

Strikes on preselected military targets inside Iran, based on extensive Israeli intelligence, are more likely, said Sima Shine, head of the Iran program at the Institute for National Security Studies. But she was skeptical that such retaliation would take place in the near term, since it would require support from Washington. If Israel retaliates, it would likely avoid Iranian civilian and economic sites, Shine said.

Israel might also choose to defer action until a later point. One option is “‘we will respond, but not immediately.’ Iran will give Israel reason to respond and retaliate in future,” said Ehud Yaari, a fellow with the Washington Institute for Near East Policy. “I think it’s very clear at this point that Israel would have to do something about Iran at some point, but not now,” he added.

The U.S., U.K. and France sought to dial down tensions after participating in Saturday’s formidable display of collective defense, urging Israel to demonstrate restraint to prevent escalation in the wider Middle East region.

“We must both be alongside Israel to ensure its security as much as possible, but call for a limit to avoid escalation,” French President Emmanuel Macron said Monday.

On Sunday, G-7 leaders issued a statement condemning Iran’s attack on Israel, offering solidarity to the Israelis and pressing for no further escalation in tensions in the Middle East. The statement was watered down from a first draft, with Japan, Canada and European officials wary of giving Israel too wide a berth for its response to the attacks, said a senior European diplomat involved in the discussions.

The original draft—reviewed by The Wall Street Journal—labeled Iran’s actions “reckless” and said Iran had “crossed yet another line” in destabilizing the region. It expressed “unconditional” solidarity with Israel and an “ironclad” G-7 commitment toward its security. All those phrases were omitted from the final version of the text. The language was changed on Gaza from calling for a cease-fire as soon as possible to seeking “an immediate and sustainable cease-fire.”

In a call Saturday evening with Netanyahu, Biden said the Israelis should proceed with caution after the successful joint operation to thwart Iran’s attack.

The U.S., France and the U.K. intercepted drones headed for Israel on Saturday night, while the United Arab Emirates and Saudi Arabia, which doesn’t officially recognize Israel, agreed privately to share intelligence. Jordan, which has repeatedly called on Israel for a cease-fire in Gaza, said it would allow the use of its airspace by U.S. and other countries’ warplanes and use its own aircraft to assist in intercepting Iranian missiles and drones, Saudi and Egyptian officials said.

Fatima AbdulKarim, Aresu Eqbali, Ken Thomas and Laurence Norman contributed to this article.