Officials described it as the kind of security emergency that could have upended the Middle East—and possibly global stability—overnight.