The onetime “axis of evil” member has built what it calls an “axis of resistance,” stretching through Iraq and Syria to Lebanon. Iranian forces or allied militias are now basically on the doorsteps of Israel and Saudi Arabia, Iran’s most important regional adversaries.

An alliance against Iran has tightened, with the United States, Israel and the gulf countries united in opposition. But if they are now more committed than ever to challenging Iran’s reach, their abilities are limited.

The United States is hesitant to get entangled in new wars in the Middle East. Mr. Trump has cut some foreign aid in Syria and said he wants to bring home the roughly 2,000 American troops deployed there fighting the Islamic State.

Gulf countries, led by Saudi Arabia, have spent billions on advanced weapons over the years but have yet to prove they can use them effectively. They are bogged down in an aerial war against Iranian-aligned rebels in Yemen, and their reliance on checkbook diplomacy has left them with little influence in Lebanon, Syria and Iraq.

By contrast, Iran has devised creative ways to nurture strategic relationships that do not require big military spending, which it cannot afford anyway.

“It is not only the money that greases the network; it is the ideology and the willingness of the Iranians to put their own skin in the game,” said Ms. Slim, the analyst. “The Saudis do not have that kind of toolbox.”