Sen. Bob Corker (R-Tenn.) has built a reputation as being one of the Senate’s most bipartisan figures. (Erik Schelzig/AP)

President Trump has his fair share of critics in Congress, but with one Sunday morning tweetstorm, he has risked making a policy rival out of someone who could have counted as an ally for his agenda.

Trump's Twitter rant against Sen. Bob Corker (R-Tenn.) comes just days before Trump is expected to announce that he will not certify Iran is in compliance with the nuclear pact with reached with world powers in 2015, the first in a highly orchestrated series of steps that White House, State Department and congressional officials — primarily Corker, as chairman of the Senate Foreign Relations Committee — have been planning for months.

It also comes as Congress is diving into tax reform, a must-win issue for the GOP if it hopes to check off any bit of its promised agenda in 2017. Corker is one of the Senate's most committed deficit hawks and outspoken members on tax policy.

But Corker is now also a free agent, after announcing last month that he would not seek reelection in 2018. Trump focused on that decision in his Sunday morning tirade against Corker, in which he accused the senator of "begging" for an endorsement Trump refused — prompting Corker to tweet that someone had "obviously missed their shift" at the "adult day care center" the White House had become.

Corker is known for his blunt and witty commentary delivered with a thick Tennessee drawl, but for months, he softened any public criticism of the Trump administration with carefully worded praise.

That began to change over the August recess, when Corker told reporters in Tennessee that "the president has not yet been able to demonstrate the stability nor some of the competence that he needs to demonstrated to be successful."

Trump later gave him grief about that comment during a meeting in the Oval Office, according to a Republican congressional official familiar with the conversation who spoke on the condition of anonymity because of the sensitivity of the private conversations. But the episode did not seem to derail what was generally a good-natured relationship between the two.

When Corker later called Trump to tell him that he had decided to retire — a decision Corker made on his 65th birthday — the president was disappointed, the official said.

So disappointed, in fact, that early last week, the president called Corker to ask him to reconsider his decision, according to Corker's chief of staff, Todd Womack — and reaffirmed that he would have endorsed Corker had he decided to run again. It was not the first time that Trump had extended such an offer of support, Womack said — directly contradicting every accusation the president tweeted out Sunday morning.

Both Trump and Corker are business executives, a background that gave them a level of mutual understanding at a time when few in Congress can claim to understand the president's motivations. But Corker has always been closer to Trump's secretary of state, Rex Tillerson — whose relationship with Trump hit a public nadir last week, after an NBC report that Tillerson had called Trump a "moron" behind closed doors.

Tillerson hasn't cultivated many relationships on Capitol Hill during his term as Secretary of State. Sen. Lindsey O. Graham (R-S.C.), who chairs the Senate subcommittee that controls the State Department's budget, has heard so little from Tillerson that he called him "the Greta Garbo of secretaries of state" in an interview last week.

But Corker and Tillerson have worked closely on everything from Russia sanctions to Iran policy to North Korea engagement. Even though they have parted ways at times — particularly on Russia sanctions — Corker remains Tillerson's staunchest defender on Capitol Hill and his closest ally. Last week, Corker told reporters that Tillerson, Defense Secretary Jim Mattis and White House Chief of Staff John F. Kelly "are those people that help separate our country from chaos."

Corker's comments have particular relevance to an announcement the president is expected to make this week about the Iran nuclear deal. Since he was a candidate, Trump has excoriated the Obama administration for agreeing to the multilateral pact, which he deemed "an embarrassment" during a speech before the United Nations General Assembly last month. That is not a position that is supported by his national security team: last week, Mattis told a senate panel that the Iran deal was important for American national security, and Chairman of the Joint Chiefs of Staff Joseph F. Dunford Jr. reiterated that he believed Iran was in compliance with the deal's terms.

Six Democratic senators had a meeting with national security adviser H.R. McMaster to discuss Iran this week and came away with the impression that he agreed with Mattis and Dunford.

Still, Trump has been adamant that he wants to discredit the deal, which is why the White House, State Department and Corker have been working together to carefully plan how the president can refuse to certify the deal without wholly extricating the United States from it.

The president must report to Congress every 90 days about whether Iran is in compliance with the deal. But Trump's opportunities to do so in the hopes that Congress will then make legislative changes to the U.S. posture on Iran's nuclear ambitions — without blowing up the deal — are limited.

According to a person familiar with coordination between the White House, the State Department and Congress, one of Republicans' key aims is to address the rampant GOP complaint that the deal only delays Iran pathway to a nuclear bomb for a decade or so, instead of erasing it forever. But to do this, they need the support of Democrats, who are loath to do anything that might jeopardize the nuclear pact and are furious about Trump's decertification plans.

If there is any Republican on Capitol Hill who stands a chance of persuading Democrats to come on board, it is Corker. As chairman of the Foreign Relations Committee, he has built a reputation as being one of the Senate's most bipartisan figures. He worked with ranking Democrat Benjamin L. Cardin (Md.) to design the law that gave Congress a chance to review the Iran deal in 2015. He has also been a driving force behind efforts to step up punitive measures against Iran for a recent spate of ballistic missile tests. He again negotiated with Cardin and other Democrats to build bipartisan support for more stringent non-nuclear sanctions, which Congress passed this summer.