MSNBC's Joe Scarborough has an up-and-down relationship with President Trump. (Left: Jonathan Ernst/Reuters; right: Ricky Carioti/The Washington Post)

Joe Scarborough is a “Trump whisperer,” according to Poynter Institute's chief media writer, James Warren. But President Trump does not always listen to the MSNBC host, even when his whispering is more like shouting.

Scarborough, a contributor to The Washington Post's opinion page, wrote on Sunday afternoon that Trump had taken a “reckless shot at a federal judge” who ruled against the president's temporary ban on entry to the United States for citizens of seven Muslim-majority countries and refugees from around the world.

Here's what Trump had tweeted:

And here's what Scarborough wrote:

When the president tries to undermine the legitimacy of the federal judiciary, he must be told in short order that the White House is picking a fight it will not win. For the sake of the country, let us hope the attacks on “so-called” Judge James Robart were merely reckless and not politically calculated. Because speeding further down that path would end in an ugly constitutional crash. …

It is yet another unforced error from a president who keeps stepping on his own good headlines while stirring deep unrest among political friends and foreign allies. As the White House improves its internal decision-making process, West Wing staffers would do the country and world a great service if it could somehow apply a similar discipline to the president’s Twitter feed.

Scarborough's column was posted at 1:37 p.m. on Sunday. Barely two hours later, Trump tweeted an even harsher message about the judge.

So much for the discipline Scarborough was talking about.

It is impossible to know with absolute certainty whether Trump read Scarborough's piece before attacking Judge James Robart again, but we know that the president pays close attention to what the former Republican congressman from Florida says. Trump's tweet — doing exactly what Scarborough said he shouldn't — sure looks like an emphatic rejection of the free advice.

That would make it the latest turn in a public relationship that swings wildly between apparent friendliness and fierce criticism.

Early in the Republican presidential primary, Scarborough and co-host Mika Brzezinski declared Trump a real contender for the GOP nomination — a view that endeared them to the real estate mogul, who was a frequent guest on their show. Though the co-hosts sought to draw a distinction between boosting Trump and merely taking him seriously, some fellow media professionals complained that Scarborough and Brzezinski seemed too cozy with the candidate.

Trump at one point thanked them for being “supporters,” though he quickly changed the label to “believers.”

Scarborough's rapport with Trump soured in dramatic fashion last February after Trump declined to disavow the endorsement of former Ku Klux Klan leader David Duke in an interview on CNN.

“I know nothing about David Duke,” Trump claimed, even though he once separated himself from the Reform Party because of Duke's membership. “I know nothing about white supremacists.”

Trump rejected Duke's endorsement soon after that interview, but Scarborough called Trump's initial comments “disqualifying.”

The rest of the campaign followed a predictable pattern. Scarborough and/or Brzezinski would criticize Trump on TV, and Trump would tweet nasty things about them. In one of the most memorable episodes, Scarborough recorded a song called “Amnesty Don,” in which he mocked Trump's immigration proposals.

After the election, however, the two sides seemed eager to reach some kind of professional understanding. Scarborough and Brzezinski met privately with Trump on New Year's Eve to discuss a possible interview.

Trump has not appeared on “Morning Joe” since then, but he did host Scarborough and Brzezinski at the White House on Jan. 29, without cameras rolling. Scarborough and Brzezinski summarized the session on their program last Monday.

Perhaps Trump and Scarborough are mending fences. But that does not mean Trump is taking Scarborough's advice to heart.

MSNBC host Joe Scarborough found himself in the middle of a media controversy after photos showed him at a party with Donald Trump on New Year's Eve. The Post's Margaret Sullivan looks into the pair's complicated relationship. (Erin Patrick O'Connor/The Washington Post)