Even the prospect of such talks represents a remarkable turnaround, coming only a few weeks after a coordinated attack on Saudi oil installations led to bellicose threats in the Persian Gulf. Any reconciliation between Saudi Arabia and Iran could have far-reaching consequences for conflicts across the region.

It was President Trump’s refusal to retaliate against Iran for the Sept. 14 attack, analysts say, that set off unintended consequences, prompting Saudi Arabia to seek its own solution to the conflict. That solution, in turn, could subvert Mr. Trump’s effort to build an Arab alliance to isolate Iran.

In recent weeks, officials of Iraq and Pakistan said, the Saudi crown prince, Mohammed bin Salman, asked the leaders of those two countries to speak with their Iranian counterparts about de-escalation.