Four months before a swarm of drones and missiles crippled the world’s biggest oil processing facility in Saudi Arabia, Iranian security officials gathered at a heavily fortified compound in Tehran.

The group included the top echelons of the Islamic Revolutionary Guard Corps, an elite branch of the Iranian military whose portfolio includes missile development and covert operations.

The main topic that day in May: How to punish the United States for pulling out of a landmark nuclear treaty and re-imposing economic sanctions on Iran, moves that have hit the Islamic Republic hard.

With Major General Hossein Salami, leader of the Revolutionary Guards, looking on, a senior commander took the floor.

“It is time to take out our swords and teach them a lesson,” the commander said, according to four people familiar with the meeting.

Hard-liners in the meeting talked of attacking high-value targets, including American military bases.

Yet, what ultimately emerged was a plan that stopped short of direct confrontation that could trigger a devastating U.S. response. Iran opted instead to target oil installations of America’s ally, Saudi Arabia, a proposal discussed by top Iranian military officials in that May meeting and at least four that followed.

This account, described to Reuters by three officials familiar with the meetings and a fourth close to Iran’s decision making, is the first to describe the role of Iran's leaders in plotting the Sept. 14 attack on Saudi Aramco, Saudi Arabia's state-controlled oil company.

These people said Iran’s Supreme Leader Ayatollah Ali Khamenei approved the operation, but with strict conditions: Iranian forces must avoid hitting any civilians or Americans.

Reuters was unable to confirm their version of events with Iran’s leadership. A Revolutionary Guards spokesman declined to comment. Tehran has steadfastly denied involvement.

Alireza Miryousefi, spokesman for the Iranian Mission to the United Nations in New York, rejected the version of events the four people described to Reuters. He said Iran played no part in the strikes, that no meetings of senior security officials took place to discuss such an operation, and that Khamenei did not authorize any attack.

“No, no, no, no, no, and no,” Miryousefi said to detailed questions from Reuters on the alleged gatherings and Khamenei’s purported role.

The Saudi government communications office did not respond to a request for comment.

The U.S. Central Intelligence Agency and Pentagon declined to comment. A senior Trump administration official did not directly comment on Reuters’ findings but said Tehran’s “behavior and its decades-long history of destructive attacks and support for terrorism are why Iran’s economy is in shambles.”

Yemen’s Iran-aligned Houthi rebels, at the center of a civil war against Saudi-backed forces, claimed responsibility for the assault on Saudi oil facilities. That declaration was rebuffed by U.S. and Saudi officials, who said the sophistication of the offensive pointed to Iran.

Saudi Arabia was a strategic target.

The kingdom is Iran’s principal regional rival and a petroleum giant whose production is crucial to the world economy. It is an important U.S. security partner. But its war on Yemen, which has killed thousands of civilians, and the brutal murder of Washington-based journalist Jamal Khashoggi by Saudi agents last year, have strained its relations with U.S. lawmakers. There was no groundswell of support in Congress for military intervention to aid the Saudis after the attack.

The 17-minute strike on two Aramco installations by 18 drones and three low-flying missiles revealed the vulnerability of the Saudi oil company, despite billions spent by the kingdom on security. Fires erupted at the company’s Khurais oil installation and at the Abqaiq oil processing facility, the world’s largest.

The attack temporarily halved Saudi Arabia’s oil production and knocked out 5% of the world’s oil supply. Global crude prices spiked.

The assault prompted U.S. Secretary of State Mike Pompeo to accuse Iran of an "act of war." In the aftermath, Tehran was hit with additional U.S. sanctions. The United States also launched cyber attacks against Iran, U.S. officials told Reuters.

The Islamic Republic has blamed "thugs" linked to the United States and other regional adversaries for orchestrating street demonstrations that have rocked Iran since mid-November, when the government hiked fuel prices.

Speaking at a televised, pro-government rally in Tehran on Monday, Salami, the Revolutionary Guards chief commander, warned Washington against any further escalation of tensions: “We have shown patience towards the hostile moves of America, the Zionist regime (Israel) and Saudi Arabia against Iran... but we will destroy them if they cross our red lines."

SCOURING TARGETS

The plan by Iranian military leaders to strike Saudi oil installations developed over several months, according to the official close to Iran’s decision making.

“Details were discussed thoroughly in at least five meetings and the final go ahead was given” by early September, the official said.

All of those meetings took place at a secure location inside the southern Tehran compound, three of the officials told Reuters. They said Khamenei, the supreme leader, attended one of the gatherings at his residence, which is also inside that complex.

Other attendees at some of those meetings included Khamenei’s top military advisor, Yahya Rahim-Safavi, and a deputy of Qasem Soleimani, who heads the Revolutionary Guards’ foreign military and clandestine operations, the three officials said. Rahim-Safavi could not be reached for comment.

Among the possible targets initially discussed were a seaport in Saudi Arabia, an airport and U.S. military bases, the official close to Iran’s decision making said. The person would not provide additional details.

Those ideas were ultimately dismissed over concerns about mass casualties that could provoke fierce retaliation by the United States and embolden Israel, potentially pushing the region into war, the four people said.

The official close to Iran’s decision making said the group settled on the plan to attack Saudi Arabia’s oil installations because it could grab big headlines, inflict economic pain on an adversary and still deliver a strong message to Washington.

“Agreement on Aramco was almost reached unanimously,” the official said. “The idea was to display Iran's deep access and military capabilities.”

The attack was the worst on Middle East oil facilities since Saddam Hussein, the late Iraqi strongman, torched Kuwait’s oil fields during the 1991 Gulf crisis.

U.S. Senator Martha McSally, an Air Force combat veteran and Republican lawmaker who was briefed by U.S. and Saudi officials, and who visited Aramco's Abqaiq facility days after the attack, said the perpetrators knew precisely where to strike to create as much damage as possible.

“It showed somebody who had a sophisticated understanding of facility operations like theirs, instead of just hitting things off of satellite photos,” she told Reuters. The drones and missiles, she added, “came from Iranian soil, from an Iranian base.”

A Middle East source, who was briefed by a country investigating the attack, said the launch site was the Ahvaz air base in southwest Iran. That account matched those of three U.S. officials and two other people who spoke to Reuters: a Western intelligence official and a Western source based in the Middle East.

Rather than fly directly from Iran to Saudi Arabia over the Gulf, the missiles and drones took different, circuitous paths to the oil installations, part of Iran’s effort to mask its involvement, the people said.

Some of the craft flew over Iraq and Kuwait before landing in Saudi Arabia, according to the Western intelligence source, who said that trajectory provided Iran with plausible deniability.

"That wouldn’t have been the case if missiles and drones had been seen or heard flying into Saudi Arabia over the Gulf from a south flight path” from Iran, the person said.

Revolutionary Guards commanders briefed the supreme leader on the successful operation hours after the attack, according to the official close to the country’s decision making.

Images of fires raging at the Saudi facilities were broadcast worldwide. The country’s stock market swooned. Global oil prices initially surged 20%. Officials at Saudi Aramco gathered in what was referred to internally as the “emergency management room” at the company’s headquarters.

One of the officials who spoke with Reuters said Tehran was delighted with the outcome of the operation: Iran had landed a painful blow on Saudi Arabia and thumbed its nose at the United States.

SIZING UP TRUMP

The Revolutionary Guards and other branches of the Iranian military all ultimately report to Khamenei. The supreme leader has been defiant in response to Trump’s abandonment last year of the Joint Comprehensive Plan of Action, commonly called the Iran nuclear deal.

That 2015 accord with five permanent members of the U.S. Security Council – the United States, Russia, France, China and the United Kingdom – as well as Germany, removed billions of dollars’ worth of sanctions on Iran in exchange for Tehran’s curbing its nuclear program.

Trump’s demand for a better deal has seen Iran launch a two-pronged strategy to win relief from sweeping sanctions reimposed by the United States, penalties that have crippled its oil exports and all but shut it out of the international banking system.

Iranian President Hassan Rouhani has signaled a willingness to meet with American officials on condition that all sanctions be lifted. Simultaneously, Iran is flaunting its military and technical prowess.

In recent months, Iran has shot down a U.S. surveillance drone and seized a British oil tanker in the Strait of Hormuz, the narrow channel through which about a fifth of the world's oil moves. And it has announced it has amassed stockpiles of enriched uranium in violation of the U.N agreement, part of its vow to restart its nuclear program.

The Aramco attacks were an escalation that came as Trump had been pursuing his long-stated goal of extricating American forces from the Middle East. Just days after announcing an abrupt pullout of U.S. troops in northern Syria, the Trump administration on Oct. 11 said it would send fighter jets, missile-defense weaponry and 2,800 more troops to Saudi Arabia to bolster the kingdom’s defenses.

"Do not strike another sovereign state, do not threaten American interests, American forces, or we will respond," U.S. Defense Secretary Mark Esper warned Tehran during a press briefing.

Still, Iran appears to have calculated that the Trump administration would not risk an all-out assault that could destabilize the region in the service of protecting Saudi oil, said Ali Vaez, director of the Iran Project at the International Crisis Group, a nonprofit working to end global conflict.

In Iran, “hard-liners have come to believe that Trump is a Twitter tiger,” Vaez said. “As such there is little diplomatic or military cost associated with pushing back.”

The senior Trump administration official disputed the suggestion that Iran’s operation has strengthened its hand in working out a deal for sanctions relief from the United States.

“Iran knows exactly what it needs to do to see sanctions lifted,” the official said.

The administration has said Iran must end support for terrorist groups in the Middle East and submit to tougher terms that would permanently snuff its nuclear ambitions. Iran has said it has no ties to terrorist groups.

Whether Tehran accedes to U.S. demands remains to be seen.

In one of the final meetings held ahead of the Saudi oil attack, another Revolutionary Guards commander was already looking ahead, according to the official close to Iran’s decision making who was briefed on that gathering.

"Rest assured Allah almighty will be with us,” the commander told senior security officials. “Start planning for the next one."