President Biden and his top national security aides believed last summer that the chances of conflict with Iran and its proxies were well contained.

After secret talks, they had just concluded a deal that led to the release of five imprisoned Americans in return for $6 billion in frozen Iranian funds and some Iranian prisoners. The militants that Tehran finances and arms — Hamas in the Palestinian territories, Hezbollah in Lebanon and the Houthis in Yemen — seemed relatively quiet. Iran even slowed enrichment of uranium at its underground nuclear sites, delaying its progress toward a weapon.

Hamas’s Oct. 7 invasion of Israel and Israel’s tough response have changed all that. Now American and Israeli officials, and a dozen countries working in concert to keep commerce flowing in the Red Sea, are confronting a newly aggressive Iran. After launching scores of attacks, from Lebanon to the Red Sea to Iraq, the proxy groups have come into direct conflict with U.S. forces twice in the past week, and Washington is openly threatening airstrikes if the violence does not abate.

Meanwhile, though little discussed by the Biden administration, the Iranian nuclear program has suddenly been put on steroids. International inspectors announced in late December that Iran initiated a threefold increase in its enrichment of near-bomb-grade uranium. By most rough estimates, Iran now has the fuel for at least three atomic weapons — and American intelligence officials believe the additional enrichment needed to turn that fuel into bomb-grade material would take only a few weeks.

“We are back to square one,” Nicolas de Rivière, a top French diplomat deeply involved in negotiating the 2015 Iran nuclear deal, said last week.

Taken together, the dynamic with Iran is more complex than at any point since the seizure of the American Embassy in 1979 after the overthrow of the shah. American and European intelligence officials say they do not believe the Iranians want a direct conflict with the United States or Israel, which they suspect would not end well. But they seem more than willing to push the envelope, enabling attacks, coordinating targeting of American bases and ships carrying goods and fuel, and walking to the edge, again, of nuclear weapons capability.

Added to the complexity of the problem is the dramatically widening scope of Iran’s aid to Russia. What began as a trickle of Shahed drones sold to Russia for use against Ukraine has turned into a flood. And now American intelligence officials believe that, despite warnings, Iran is preparing to ship short-range missiles for use against Ukraine, just as Kyiv is running short on air defense and artillery shells.

It is a reflection of a sharply altered power dynamic: Since Russia’s invasion of Ukraine, Iran no longer finds itself isolated. It is suddenly in an alliance of sorts with both Moscow and China, two members of the U.N. Security Council that, in a past era, supported Washington in trying to limit Iran’s nuclear program. Now, that deal is dead, ended by former President Donald J. Trump five years ago, and suddenly Iran has two superpowers not only as allies, but as sanctions-busting customers.

“I see Iran as well positioned, and it has checkmated the U.S. and its interests in the Mideast,” said Sanam Vakil, the director of the Middle East and North Africa program at Chatham House. “Iran is active on all the borders, resistant to any sort of change from within, while enriching uranium at very alarming levels.”

Mr. Biden entered office intent on reviving the 2015 Iran nuclear deal, which contained Tehran’s nuclear program for three years until Mr. Trump withdrew from it in 2018. After more than a year of negotiations, an accord was all but reached in the summer of 2022 to restore most of the agreement. It would have required Iran to ship its newly produced nuclear fuel out of the country, just as it had in 2015.

But the effort collapsed.

For the next year, Iran accelerated its nuclear program, for the first time enriching uranium to 60 percent purity, just shy of the 90 percent needed to produce weapons. It was a calculated move intended to show the United States that Tehran was just a few steps from a bomb — but short of going over the line, to forestall an attack on its nuclear facilities.

In the summer of 2023, however, Brett McGurk, Mr. Biden’s Middle East coordinator, quietly pieced together two separate deals. One got the five American prisoners released in return for several imprisoned Iranians and the transfer of $6 billion in Iranian assets from South Korea to an account in Qatar for humanitarian purposes.

But the second deal — one Mr. Biden did not want revealed — was an unwritten agreement that Iran would restrict its nuclear enrichment and keep a lid on the proxy forces. Only then, the Iranians were told, could there be talks on a broader deal.

For a few months it appeared to be working. Iranian proxies in Iraq or Syria did not attack American forces, ships ran freely in the Red Sea and inspectors reported that enrichment had been drastically slowed.

Some analysts say it was a temporary, and deceiving, quiet. Suzanne Maloney, the director of the foreign policy program at the Brookings Institution and an Iran expert, called it “a Hail Mary they hoped would preserve some calm in the region through the election.”

American intelligence officials say Iran did not instigate or approve the Hamas attack in Israel and probably was not even told about it. Hamas may have feared that word of the attack would leak from Iran, given how deeply Israeli and Western intelligence have penetrated the country.

But as soon as the war against Hamas began, Iran’s proxy forces went on the attack. There were, however, significant indications that Iran, facing its own domestic problems, wanted to limit the conflict. Early on, Israel’s war cabinet discussed a pre-emptive strike on Hezbollah in Lebanon, telling the Americans that an attack on Israel was imminent and part of an Iranian plan to go after Israel from all sides.

Mr. Biden’s aides pushed back, arguing that the Israeli assessment was wrong, and deterred the Israeli strike. They believe they prevented — or at least delayed — a broader war.

Yet in recent days the threat of a war with Hezbollah has resurfaced. The group fired scores of rockets at an Israeli military post on Friday and Saturday in what it called a “preliminary response” to the killing last week of a senior Hamas leader, Saleh al-Arouri, in Lebanon.

Some in the Israeli government, like Defense Minister Yoav Gallant, have warned that complacency about Hamas’s intentions should not be replicated with Hezbollah, which is thought to have as many as 150,000 missiles aimed at Israel and has trained some of its troops, the Radwan Force, for a cross-border invasion.

But in Washington, the concern now is less about a Hezbollah attack on Israel than an Israeli strike on Hezbollah. The United States has told Israel that if Hezbollah comes over the border, Washington will support Israel — but not the other way around.

Hezbollah appears to have been careful so far not to give the Israelis an excuse for a military operation. Still, Iran has built Hezbollah, the most powerful force in Lebanon, as protection for itself, not the Palestinians. Hezbollah is a deterrent against any major Israeli attack on Iran, given the carnage its thousands of missiles could inflict on Israel.

That is a prime reason Iran wants to keep Hezbollah out of the war in Gaza, said Meir Javedanfar, a lecturer on Iran at Israel’s Reichman University. Otherwise, Israel might go after Iran directly, he said, noting that Naftali Bennett, a former prime minister, has long pushed cutting off “the head of the octopus, not just the legs,” like Hamas and Hezbollah.

“I see little interest in Iran escalating at this stage,” Ms. Maloney of the Brookings Institution said, “because they’re achieving most of their interests without that.”

But American officials say that Iran does not have operational control over many of its proxies, and that the intensity of the attacks far from the Lebanon-Israel border could well be the spark for a larger conflict.

Iranian proxies in Iraq and Syria have conducted more than 100 such attacks, which have drawn brief counterstrikes when they caused American casualties. On Thursday, an American missile strike in Baghdad — a rare event — killed Mushtaq Jawad Kazim al-Jawari, a deputy commander of an Iranian-backed militia who was “actively involved in planning and carrying out attacks against American personnel,” the Pentagon said.

The piece of the conflict with the most immediate global impact has been centered on the Red Sea, where Houthi forces in Yemen, using Iranian intelligence and weapons, are targeting what they call “Israeli ships.” In fact, they appear to be targeting all ships with heat-seeking missiles that cannot discriminate between targets and fast boats used to board and take over tankers.

When the U.S. Navy came to rescue a Maersk cargo ship under attack last weekend, the Houthis opened fire on Navy helicopters. The Navy pilots returned fire and sank three of the four Houthi boats, killing 10, the Houthis reported.

Maersk, one of the world’s largest shippers, has suspended all transits through the Red Sea “for the foreseeable future,” meaning that it is routing around the fastest path between Europe and Asia — the Suez Canal. Companies around the world, from Ikea to BP, are already warning of supply-chain delays.

Washington has pulled together a coalition of nations to defend the ships, but it is heavily dependent on the American naval presence. And so far Mr. Biden has been reluctant to attack the Houthis in Yemen, but that appears to be changing, officials say.

The United States and 13 allies signed on to a statement last week giving what an administration official called a “final warning” to the Houthis to stop “these illegal attacks and release unlawfully detained vessels and crews.” It did not mention Iran.

The Pentagon is refining plans for how to hit Houthi launching sites in Yemen, and some sort of assault on Houthi assets in Yemen is likely as soon as there is another attack, officials suggest, as a sharp warning to try to restore deterrence.

“At this point a significant military response is needed against the Houthi rebels, who are really Iranian pirates,” said James G. Stavridis, a retired admiral. “Our experience with Somali pirates years ago shows that you can’t just play defense; you have to go ashore to solve a problem like this. That is the only way for Iran to get the message.”

“The idea that we are simply going to patrol the Red Sea, the size of California,” with a “half-dozen police cars — our ships out there — is unrealistic,” he said.

Mr. Biden faces hard choices. He pulled back from the Middle East to focus on competing with and deterring China. Now he is being sucked back in.

“The U.S. has built up a matrix of deterrence, signaling that it is not interested in a regional war but is prepared to intervene in response to Iran’s provocation,” said Hugh Lovatt, a Middle East expert for the European Council on Foreign Relations. But the presence of American carriers and troops makes Washington more exposed, he said. “So this matrix of deterrence could be a driver of escalation.”

Looming over all these possible conflicts is the future of Iran’s nuclear program, with its long-running potential for direct confrontation with the West.

The years of diplomatic negotiations, covert action to disable Iran’s nuclear centrifuges and Israeli assassinations of Iranian scientists have been focused on one goal: extending the time it would take Iran to assemble the fuel for a bomb. When the 2015 deal was reached, the Obama administration celebrated its greatest achievement — that timeline, it contended, was more than a year.

Today, as Mr. Rivière, now France’s U.N. ambassador noted, “we are talking about a couple of weeks or so,” a situation that in previous years would have almost certainly prompted a crisis. (Fashioning that fuel into a working bomb would probably take a year or more, however, giving more time for the West to react.)

The Biden administration has said little, officials concede when speaking anonymously, because its options are so limited. With Iran supplying Russia with arms and selling oil to China, there is no chance of Security Council action.

And Mr. Biden’s aides have given up interest in reviving the 2015 accord, because it is now outdated. As initially negotiated, it would allow Iran to produce as much fuel as it wants starting in 2030.

“Iran is enriching because they can,” Ms. Maloney said. “Their goal has always been to wait out pressure and give themselves the option of a weapons program.”