American military and intelligence officials were stunned at the precision, scale and sheer boldness of what they later concluded was an Iranian attack.

Four months ago, a swarm of low-flying armed drones and cruise missiles struck oil tanks in the central hub of the Saudi petroleum industry, catching Washington by surprise and temporarily knocking out 5 percent of the world’s oil supply. Almost no country in the region — Israel may be the exception — could have defended against it.

The Iranian attack on American military posts in Iraq early Wednesday — the only direct attack on the United States or its allies claimed by Iran since the seizure of the American Embassy in 1979 — relied on ballistic missiles and inflicted little damage.

But with tensions between the United States and Iran at the highest level in four decades, the unexpected success of the September strike on the Saudi oil facilities is a stark reminder that Tehran has an array of stealthier weapons in its arsenal that could pose far greater threats if the hostilities escalate.