Even before Donald Trump was elected U.S. president, fierce opposition to the Iranian nuclear deal by hardliners in both Tehran and Washington had seemed to set the two nations on a collision course. Yet a closer look at the Trump administration’s oft-bellicose stance and Iran’s own words and actions also reveals elements of restraint.

Confrontation with Iran was virtually guaranteed in the aftermath of the 2015 nuclear deal as hardliners quickly mobilized in opposition. Within months of concluding the deal, Iran began testing a new precision-guided ballistic missile in defiance of UN resolutions. Meanwhile, candidate Trump repeatedly denounced the nuclear pact, pledged to renegotiate a better deal, and vowed to keep Iran from going nuclear.

So when Iran conducted another ballistic missile test just days after the inauguration, the response from the brand-new administration was predictably combative and confrontational. Then-National Security Advisor Michael Flynn issued a White House statement warning that the Trump administration “will no longer tolerate Iran’s provocations.” President Trump himself tweeted that “Iran has been formally PUT ON NOTICE for firing a ballistic missile” and ominously asserted that Iran was “playing with fire.”

This aggressive tone led some analysts to wonder whether the U.S. and Iran were beginning to slide inevitably toward war. Flynn believes that Iran is at the center of an alliance that includes radical Islamic terrorist groups dedicated to our destruction. His replacement had not yet been named at press time, but other senior administration officials also have grave concerns about Iran. CIA Director Mike Pompeo has been a strong advocate of discarding the nuclear deal. Defense Secretary James Mattis has characterized Iran as a “revolutionary cause devoted to mayhem.” Meanwhile, Arab Gulf allies and Israel alike have been cheering the hints at a more aggressive U.S. effort to curb Iranian influence.

Despite these pressures, however, both the Trump administration and leaders in Tehran have also taken measured steps that have been carefully calibrated to avoid unintended escalation. Iranian officials downplayed the significance of the ballistic missile testing, calling them “for defensive purposes” only and insisting that they were “not a message to the new U.S. government.” Most importantly, Iran has complied with the terms of the nuclear deal, seeking to avoid providing the Trump administration a pretext for a forceful reply. For its part, the White House has reacted to the tests by imposing limited and targeted sanctions against “people and companies alleged to be involved in the missile program.”

The ultimate outcome of an open military confrontation with Iran, in favor of the U.S., may well not be in doubt, but it will likely be costly.

Nonetheless, as Paul Pillar, former senior CIA intelligence officer for the Middle East, noted in December, “ingredients are falling, tragically, into place for a possible war with Iran.” Many of the most influential voices surrounding President Trump view Iran as a malevolent force that must be confronted. Similarly, hardline Iranian leaders are frustrated that sanctions are being eased slowly; they may be looking to pick a fight with the Americans in Yemen, Syria, or in and around the Hormuz Strait. Iran expert Karim Sadjadpour recently outlined just how the Trump Administration might find itself quickly walking up the escalatory ladder to war with Iran.

Iran, it seems, may be the first meaningful test of the Trump administration and its national security officials. The ultimate outcome of an open military confrontation with Iran, in favor of the U.S., may well not be in doubt, but it will likely be costly. Compared to Iraq, Iran has twice the population and nearly four times the land, which offers a forbidding terrain of cities, mountains, and deserts. Even a more limited campaign of strikes on Iranian nuclear facilities will at best delay Iran’s ability to acquire a nuclear weapon by “up to four years” and will actually increase “the likelihood of Iran becoming a nuclear state.” Iran also has many conventional options for retaliating against the U.S. or its regional allies, ranging from its extensive missile capabilities, small submarines, fast attack boats, and minelayers. Of course, Iran could also mobilize proxy forces in Iraq, Lebanon, Syria, and Afghanistan to increase attacks on American forces and interests in the region.

The successful management of these challenges with Iran will require a deft application of the full range of American diplomatic, economic, and military power. We may well soon see if President Trump and his national security team are up to this challenge.