The deadline to certify Iran's compliance to Barack Obama's landmark nuclear deal was nearing. Trump had campaigned as an ardent opponent of the accord, proclaiming to raucous rallies of supporters that he'd tear the deal to shreds.
By that point in his term, Trump had already been convinced to certify the agreement once. But with his legislative agenda stalled and a scant few of his campaign promises fulfilled, he was loath to delay yet another core promise.
In Washington for only a few days in between back-to-back visits to Europe, Trump huddled with his top national security aides -- including Secretary of State Rex Tillerson, Defense Secretary James Mattis, and National Security Adviser H.R. McMaster -- to hear their recommendations. To a person, all recommended Trump keep the deal intact to preserve leverage over Tehran and avoid isolating the United States among its allies.
It was an answer he didn't like. Trump made known in "forceful, not uncertain" terms that he was disappointed by the options his team had been presenting him, according to a person familiar with the discussions, who described Trump's reaction as an "extended outburst." The session lasted close to an hour.
The advisers regrouped, developed a plan they believed would satisfy Trump's demands, and presented it to him a week later after he'd returned from a quick visit to Paris and a weekend at his golf resort in New Jersey.
But that plan was insufficient in his mind, too. And so on July 17, Trump again went forward with certifying the agreement, notifying his team it would be the last time he did so. In an interview a few days later, Trump aired his resentments publicly, saying he was reluctantly taking his team's advice -- this time.
In the months since then, his aides -- under angry orders from the President -- devised a solution that would allow Trump to publicly reject the deal while stopping short of withdrawing from a global agreement that even his top advisers believe is working to prevent Iran from obtaining a nuclear weapon.
"As I have said many times, the Iran deal was one of the worst and most one-sided transactions the United States has ever entered into," Trump said in remarks from the White House diplomatic reception room on Friday, conceding later: "But what's done is done, and that's why we are where we are."
What Trump announced on Friday amounts to a middle road, crafted by a team of advisers who have warned the President that a full withdrawal from the deal -- which he would prefer -- could destabilize the region further and isolate the United States from its allies.
Spearheading the plan was Tillerson, who has suffered a testy relationship with Trump over the past several months. Part of the President's irritation centered on the Iran deal, which he felt had been insufficiently confronted by his top diplomat. Tillerson, meanwhile, felt Trump had only a loose grasp on global affairs, the Iran deal included.
Over the late summer and early fall, Tillerson discussed a path forward with lawmakers. He offered the broad outlines of a strategy to foreign ministers on the sidelines of last month's United Nations meetings in New York.
The plan he formulated does "as much to contain Trump as it does Iran," according to a senior official involved in the planning, meaning it forestalls Trump immediately throwing out the nuclear agreement.
"Trump has essentially forced his own national security team to fall into line with the decision that they don't agree with, and to find some rationale for that decision," said Ben Rhodes, a deputy national security adviser to Obama who helped shepherd to nuclear agreement. "And so you're looking at an administration that is contorting itself in order to justify the irrational decision of the President of the United States."
Trump's anger at his team over the matter lays bare some of the divisions within the administration, which has been pulled in opposing directions on a range of topics since Trump took office in January.
While Trump and his close circle of aides are intent on achieving the goals he laid out on last year's campaign, other members of his team -- including those who didn't play a role on his successful bid for president -- have taken sometimes differing views.
On the Iran deal, Trump faced the inconvenient reality that Iran is technically complying with the provisions laid out in the 2015 deal, which was signed by six countries and which still enjoys ardent support from American allies in Europe.
Trump decertified Iran's compliance with the deal, but passed the buck to Congress, which now has 60 days to either impose new economic sanctions -- and scuttling the deal as a result -- or do nothing, which would keep the deal in place. The administration is pressuring lawmakers to pass new "triggers" that would prompt mandatory sanctions on Iran, as well as address the "sunset" provision, considered by Trump a major weakness of the deal.
But the prospects of Congress agreeing on parameters to improve the deal aren't considered high. For starters, the man responsible for shepherding a plan through -- Senate Foreign Relations Committee Chairman Bob Corker -- is embroiled in a bitter feud with the President, who has impugned his height
. And Democrats will likely be required for passage of any measure, and have shown little appetite for helping Trump undermine Obama's legacy.
If they don't pass something, Trump has been clear that he'll scrap the deal for good.
"I may do that. I may do that. The deal is terrible," Trump told reporters on the White House south lawn on Friday before boarding his idling helicopter. "We'll have Congress take a look at it, and I may very well do that. But I like a two-step process much better."