ANALYSIS: How the US helped to defuse Saudi Arabia's dangerous gambit with Lebanon The U.S. along with France defused a potentially dangerous play by Saudi Arabia.

LONDON -- The recent bizarre episode of Lebanon's prime minister resigning while in Saudi Arabia and on Saudi TV sparked confusion around the world. But few may have realized how momentous and potentially dangerous the incident actually was.

It turned out to be an impulsive power play by one of the Trump administration's most important allies in the Middle East. And it might have brought the region dangerously close to war had it not been for deft intervention by the United States and France.

At a time when the U.S. seems to be in retreat from the world stage, with many vacant positions in American embassies in crucial countries - including Saudi Arabia - and big reductions in State Department staff, this episode brought into sharp focus the U.S.'s still-essential role as an international power broker. The diplomatic response to the incident also marked France's return to the international stage.

"U.S. diplomats and decision-makers played the major role in pushing back against Saudi Arabia's impulsive move and identifying the pathway to defuse this crisis," said Randa Slim, director of conflict resolution at the Middle East Institute in Washington, D.C.

It all started when Saudi Crown Prince Mohamad Bin Salman decided to simply bench his Lebanese ally, Prime Minister Saad Hariri, whom the prince saw as too mellow in the face of Iranian influence in the region, and replace him with his older brother, Bahaa, according to multiple sources.

President Donald Trump’s recent praise of Hariri for his efforts in the fight against ISIS plus fears that his resignation could spark a devastating war between Lebanon, specifically Hezbollah, and Israel – two matters of fundamental importance to the U.S. in the region – didn’t seem to shield Hariri from the crown prince’s new plans in the region.

Prince Mohamad was intent on rolling back Iranian interference in a more robust and direct way, and Lebanon was his arena du jour.

Thus began the high-stakes drama that played out over two weeks and which revealed both the governing style of the man expected to rule Saudi Arabia for the coming decades and the pitfalls of leaving the two competing regional powers in the Middle East -- Iran and Saudi Arabia -- unchecked.

The events that followed required many delicate and private diplomatic conversations, involving the United States, France, Saudi Arabia and Iran, and some elaborate stage managing.

The Saudi plan

Hariri was in Saudi Arabia two days before his resignation, a visit that left him upbeat and confident and apparently with no indication that the Saudis intended to dramatically pull their support for him.

He left expecting to return within days for more meetings with the Saudi leadership, but certainly not to be instructed to resign or to be barred from leaving Saudi Arabia, according to Lebanese sources close to him. What caused the shift in tone in those 48 hours has not yet been fully established.

Nevertheless, it appears the Saudi plan, in the works for some time, was to replace Hariri with his brother, Bahaa, per multiple sources. The two have been at odds since their father, the late Lebanese prime minister, Rafik Hariri, was assassinated in 2005.

"Bahaa Hariri was extremely interested and angling for the position. In private discussions in Washington, D.C., he was voicing his displeasure with his brother’s policies and advocating a more hawkish position against Hezbollah and Iran," according to Firas Maksad, deputy executive director of the Arabia Foundation, a think tank in Washington.

Bahaa didn’t get the reception he was hoping for. "People weren't too excited about him taking on Saad's position," according to a U.S. diplomatic source.

ABC News has asked the Saudi embassy in Washington for comment on the Hariri crisis but the request is still under review.

Hariri, who has since returned to Lebanon and put his resignation on hold says he wasn’t forced to resign and was not held captive in Saudi Arabia.

"I wanted to cause a positive shock," he repeated, to warn Hezbollah, his partner in Lebanon's government, of the dangers posed by its central role within the anti-Saudi Iranian axis in places like Syria, Yemen and Bahrain.

Countering Iran is everything

The Saudi crown prince's gambit showed his determination to counter Iran, said Slim of the Middle East Institute.

"One principal plank in [his] foreign policy is that Saudi Arabia will deploy all resources necessary to contest Iranian influence in the region," Slim said.

As the Saudi military has been fighting a two-year war in Yemen against Iranian-backed rebels whom it contends are aided militarily by Hezbollah, Hariri has led a government in which Hezbollah held veto power.

This was a situation the Saudi leadership was no longer willing to accept.

"The Hariri family, and its political party, has long been the main recipient of Saudi patronage, beholden both financially and politically, in Lebanon," according to Faysal Itani, resident senior fellow at the Atlantic Council, another Washington think tank.

So Saudi Arabia decided to call in its chips, inviting the Hariri family to visit to rubber-stamp a leadership change in Lebanon.

But the Hariris in an unprecedented show of defiance refused and called on foreign allies, namely France, for help, per sources close to the family.

Hence began 10 days of diplomatic negotiations, led by France with crucial American assistance that played out from Riyadh to Beirut and Tehran.

France steps up

This was the perfect moment for France’s ambitious new president, Emmanuel Macron, to try to reclaim the once-pivotal role his country had in the region before being sidelined by America.

France has a deep historical relationship with Lebanon and, unlike America, has also preserved diplomatic relations with Iran and Hezbollah’s political wing, in addition to having a relationship with Saudi Arabia. It used all three assets in managing this crisis.

French President Emmanuel Macron made a last-minute stop in Riyadh on Nov. 9 on his way back from his state visit to the United Arab Emirates, upon the recommendation of the Emirati crown prince, a close Saudi ally.

In a meeting with Prince Mohamad, the French president mentioned the case of Hariri and Lebanon, a French diplomatic source who wouldn’t comment on the Saudi crown prince's reaction told ABC News. "They also discussed the regional situation including Iran’s policies as well as the missile launched from Yemen on Riyadh."

At the time of the meeting, Macron was the first high-level foreign official to link Iran to the Yemeni missile launch, a position later taken also by the U.S. military and United Nations monitors, as reported by Reuters on Nov. 30.

Macron's early backing of Saudi’s complaints against Iran helped to open communications. But it wasn't enough to resolve the Hariri situation that day.

A video posted to the French president’s Twitter account showed him thanking the Saudi crown prince for making the time to see him, a respectful deference that is appreciated in Saudi Arabia.

Around the same time, the United States, seemingly absent from the management of this crisis, worked behind the scenes to deal a crucial blow against the Saudi plan.

US deals death blow to Saudi plan

On Nov. 10, Thamer al Sabhan, the Saudi minister for Gulf affairs, who also oversaw policy toward Lebanon, met with David Satterfield, the top U.S. official on the Middle East at the State Department. It was a rocky meeting, in which Satterfield made it clear that the U.S. did not support the Saudi handling of Hariri.

While the U.S. administration agrees with the Saudi leadership on the need to more robustly confront Iran and Hezbollah, it advocates a more calibrated approach in Lebanon, mindful that a disintegration of the state there would complicate American efforts to both resolve the Syrian crisis and continue stabilizing Iraq.

Sabhan received the same message from the U.S. National Security Council, according to two Lebanese sources and one American official who spoke on condition of anonymity because they were not allowed to comment publicly. Both the State Department and the NSC had no comment when contacted by ABC News.

The Saudi minister was asked to take a step back shortly after meeting with the U.S. official, but it was just a tactical adjustment, according to Maksad of the Arabia Foundation. "The Saudi position remains that it is unacceptable for its ally in Lebanon, namely Hariri, to provide political cover for Hezbollah."

Nov. 10 also marked the first time that a foreign official indicated Hariri may not be fully free in Saudi Arabia, with a French foreign ministry spokeswoman saying, "We wish for Mr. Hariri to have his full freedom of movement and be fully able to play the essential role that is his in Lebanon."

This came after Hariri met with the U.S. charge d’affaires and the French ambassador in Riyadh. Lebanese sources close to Hariri maintain he was monitored in these meetings by a Saudi note-taker, a highly unusual presence in diplomatic conversations in which Saudi Arabia is not involved. The French foreign ministry would not comment on that.

Later that afternoon, U.S. Secretary of State Rex Tillerson reaffirmed support for Hariri as prime minister of Lebanon, and in an apparent reference to both Saudi and Iranian interference in Lebanon, cautioned against, "using Lebanon as a venue for proxy conflicts." He also encouraged Hariri to return to Lebanon and officially step down, discrediting assassination-plot fears that Hariri had mentioned in his resignation speech.

The next day, the White House joined the chorus of support for Hariri when it put out a statement referring to him as a "trusted partner."

"The U.S. policy remains to push back against Iran and its proxies," says Itani of the Atlantic Council, "but since doing it in Iraq and Syria, where it matters most, comes at the highest cost, it is doing it by supporting the Saudi war effort in Yemen, by imposing calibrated financial sanctions against Hezbollah in Lebanon, and by supporting the Lebanese Armed Forces.”

With such open U.S. support for Hariri, the Saudi leadership realized its initial plan wouldn’t succeed.

France and art of compromise

France leveraged its lines of communication with Hezbollah and Iran as well as its relationship with Saudi Arabia to work on achieving a satisfactory compromise while also managing the optics of the delicate operation.

On Nov. 12, Hariri gave his first interview since his resignation. It was conducted by the star anchor of his own television network at the home he owns in Riyadh. This was the first step toward ending the crisis, per a French diplomatic source. But there were still thorny negotiations ahead that required careful stage managing.

That same day, French foreign minister Jean-Yves Le Drian, and his chief of staff, the former French ambassador to Lebanon, Emmanuel Bonne, who was involved in managing the crisis, planted a Lebanese cedar tree in the garden of the French foreign ministry in Paris.

"Of course this was highly symbolic. Choosing to plant a Lebanese cedar, at that moment, was meant to signal France's deep-rooted relationship with and attachment to Lebanon's stability and integrity," per the French diplomatic source.

Le Drian was expected in Riyadh three days later to discuss bilateral interests as well as find a solution to the Hariri crisis. This involved ongoing negotiations over his return to Lebanon and the elaboration of the plan to put his resignation on hold. Just as he was arriving, Macron offered Saudi Arabia a face saving end to the Hariri fiasco. He explained in a statement that he was inviting Hariri and his family to spend a few days in Paris, after having discussed the matter with the Saudi crown prince.

By the time Le Drian left Riyadh the evening of Nov. 16, French diplomats felt confident they had worked out a deal with Saudi leadership and Hariri would head to Paris two days later.

The need for France to stage-manage the Hariri-Saudi relationship didn't stop then, though. Hariri's family, who is based in Saudi Arabia, was publicly hosted twice at the Elysee, in an effort partly aimed at dispelling concerns for their well-being in the Kingdom. Yet, speculation has persisted in Lebanon that Hariri's wife and school-aged children will remain in Paris, instead of returning to Saudi Arabia where they have spent all their lives, as result of what is perceived as a souring of the relationship.

Negotiating a regional compromise

Many in Lebanon have noted the irony of Hariri’s need for French assistance to return to Lebanon on the eve of the country's 74th anniversary of independence from France. Yet securing his return was not the thorniest part. Reaching a regional agreement that would shield Lebanon from the larger conflict is an uphill battle.

There were some initially encouraging signs though. On Nov. 20, two days before Hariri's return to Lebanon, Hezbollah chief Hassan Nasrallah gave the most noteworthy rhetorical concession to date, announcing in a speech, "I categorically deny any role of any member of Hezbollah in launching this missile." Nasrallah also toned down his inflammatory rhetoric toward Saudi Arabia. This helped allow Hariri to put his resignation on hold.

Nevertheless, that was followed by consecutive defiant and inflammatory statements by Iranian and Saudi officials, continuing to stoke tensions between the rival regional powers. Meanwhile, Hariri's ongoing rapprochement with pro-Iranian parties in Lebanon, marking the failure of the Saudi gambit, has renewed Lebanese fears of punishing Saudi-led financial measures against the country. France is expected to host a meeting of the Group of International Support for Lebanon this week, as part of its continued efforts to bring about a compromise and stabilise the situation.

"Their plan to replace Saad Hariri with someone who espouses a tougher and more confrontational line against Hezbollah has backfired," said Slim. “If the objective was to push the Lebanese to rally against Hezbollah, this move did exactly the opposite: It diverted attention away from Hezbollah and focused it instead on the humiliating and arrogant Saudi treatment of Hariri."

Though Hariri has called the role Macron played in the crisis "historic," the crisis is not over yet. The deal still being worked out for Lebanon depends on precarious agreements, vulnerable to Saudi-Iranian tensions that, despite the efforts of French mediation, continue unabated.

ABC News' Conor Finnegan contributed to this report.