As negotiations to halt more than 10 months of fighting in Gaza drag out with no clear breakthrough in sight, U.S. officials see a silver lining: Iran and Lebanese Hezbollah have for now held off on what many feared would be a major retaliatory attack against Israel.

For three weeks, the Middle East appeared on the brink of a regional war after Iran and its proxy said they would strike back against Israel for its twin killings of a senior Hamas leader in Tehran and a Hezbollah commander in Beirut. The Biden administration issued a series of dire warnings last week, saying the attack could come soon.

But no massive attack has materialized.

Biden administration officials say Iran doesn’t want to interfere with U.S. and Arab-mediated cease-fire talks between Israel and Hamas, in part because a deal would pave the way for the U.S. to reduce its stepped-up military footprint in the Middle East—a priority for Tehran.

The Iranians see the threat of an attack “as leverage for bringing about Israeli concessions to get the cease-fire in place, and also providing motivation to the U.S. to do all they can to push all sides,” a U.S. official said. “They realize the opportunity here to influence things in support of their strategic aims.”

Iran continues to message that it is putting off a retaliatory strike as talks unfold. In a statement to The Wall Street Journal, Iran’s mission to the United Nations said any response must both punish Israel and deter future strikes in the country, but also “must be carefully calibrated to avoid any possible adverse impact that could potentially influence a prospective cease-fire.”

“The timing, conditions, and manner of Iran’s response will be meticulously orchestrated to ensure that it occurs at a moment of maximum surprise; perhaps when their eyes are fixed on the skies and their radar screens, they will be taken by surprise from the ground—or perhaps even by a combination of both,” the statement said.

Hopes that a cease-fire might ease tensions in the region, including with Iran, were thrown into doubt Tuesday night, when Secretary of State Antony Blinken indicated that a breakthrough wasn’t imminent. “Time is of the essence,” he told reporters, citing the “fierce urgency” needed to get a deal done and warning all parties not to escalate tensions further.

Blinken’s remarks were at odds with the optimism mediators expressed in recent weeks that a deal was imminent after Hamas dropped its demand for an explicit commitment to a permanent cease-fire. It also appeared to be a setback from Monday, when, after meeting in Jerusalem with Israeli Prime Minister Benjamin Netanyahu , Blinken announced that Israel had accepted a proposal to bridge gaps holding up the deal for a cease-fire and hostage release.

Blinken declined to provide details, however, and the Israeli leader hasn’t publicly backed the agreement.

A group of hostage families on Tuesday said Netanyahu told them he was “not sure” a deal could be reached and that Israel “will under no circumstances” leave a buffer zone along Gaza-Egypt border and an area that bisects the enclave’s north and south. Netanyahu has told Israeli officials he persuaded Blinken of the need for Israeli troops to remain in both places.

A senior U.S. official traveling with Blinken swiftly criticized the remarks attributed to Netanyahu, which saw the Israeli leader hold his ground on a prime sticking point. “Maximalist statements like this are not constructive to getting a cease-fire deal across the finish line,” the official said.

President Biden, fresh from addressing the Democratic National Convention in Chicago, appeared to blame the militant group for the lack of visible progress. “Hamas was now backing off,” he said early Tuesday morning. But he said a cease-fire was “still in play.”

Hamas replied that Biden’s remark was misleading and didn’t reflect the true position of the movement. The militant group says it has been eager to reach an agreement that would halt the conflict, but the most recent proposal includes Israeli conditions that it doesn’t accept.

A potential cease-fire isn’t the only part of Tehran’s consideration in weighing a potential attack on Israel. Iran also fears that directly attacking Israel for a second time this year would lead to a broader regional war, a senior administration official said. Such an outcome would come at huge cost to Iran, where the economy is already struggling, and would likely draw the U.S. deeper into the conflict.

“They don’t want to go down that path,” the official said.

Iran might not hold back indefinitely, however. Iran will respond to the killing of Hamas leader Ismail Haniyeh in Tehran, regardless of the diplomatic situation, according to Steven Cook, a senior fellow for the Middle East at the Council on Foreign Relations. “It would be a strategic setback if they don’t,” he said.

Cook added that an attack by Iran during the talks would also make it easy for Israel and Hamas to blame Tehran for a collapse in negotiations—a convenient foil for two sides that keep finding ways not to reach an agreement.

On Tuesday, Alimohammad Naini, a spokesman for the Iranian Revolutionary Guard, told state media that Tehran is looking at different options, and whatever it chooses “might not be a repeat of previous operations.” A spokesman for Iran’s mission at the U.N. didn’t respond to a request for comment.

In April, Iran launched more than 300 drones and missiles at Israel, but almost all of them were intercepted by Israel, the U.S, and its allies.

U.S. officials also tout their own diplomatic and military messaging as potentially deterring Iran, at least for now.

The movement of U.S. aircraft carriers and jet fighters into the region sent a clear signal to Tehran, in addition to the messages Washington sent directly and indirectly to the Iranian regime, a senior administration official said. “We know they are paying attention to our messages, we have indications,” the official added.

If the cease-fire talks do collapse, however, Iran may use that diplomatic breakdown to legitimize an eventual attack on Israel, said Dana Stroul of the Washington Institute for Near East Policy, who served as the top Pentagon official overseeing Middle East policy until February.

“Either way its leaders are working to position Iran as a regional leader rather than the epicenter of the region’s woes,” she said.

Write to Lara Seligman at lara.seligman@wsj.com , Alexander Ward at alex.ward@wsj.com and Alan Cullison at alan.cullison@wsj.com