President Trump's strained relationship with American intelligence agencies faces its biggest test now that a CIA whistleblower has accused him of abusing his position to ask Ukraine to investigate his political rival Joe Biden.

The rift between Trump and the nation’s spy agencies opened before he took office, when he compared CIA officers to Nazis. Since then, he has clashed publicly with his own spy chiefs, shared classified material with Russian visitors to the Oval Office, and tweeted out a surveillance photograph from his security briefing. Many retired CIA officers reacted with public scorn for Trump.

Since Gina Haspel, 63, became CIA director in May 2018, fewer differences have been aired and an uneasy peace has reigned. But the emergence of the whistleblower has put all that under threat.

Since the whistleblower came forward with his complaint, centered on a July 25 phone call with Ukrainian president Volodymyr Zelensky, Trump has used the words “treason” and “coup” to describe efforts to impeach him, referred to anyone providing information to the CIA officer as a “spy,” and suggested they should be executed.

This leaves Haspel, a career CIA officer and former London station chief, to rebuild relationships damaged on both sides, according to Fred Fleitz, former National Security Council chief of staff.

“I don’t know whether she’ll be speaking out, but I think she’ll be doing her best to reassure the president about the intelligence that he gets and to reassure the professionals at Langley that the president appreciates what they are doing and we can move past this incident,” he said.

Both sides blame the other for the dysfunction. Trump allies say the trouble began with the intelligence community’s distrust of the Republican nominee in 2016. Harry Reid, the then-minority Senate leader, implored officials delivering classified briefings not to divulge secrets after Trump encouraged Russian hackers to hunt down Hillary Clinton’s missing emails.

Then days before his inauguration, intelligence agencies revealed they believed that Russia ran an influence campaign to help Trump triumph over Clinton — a conclusion interpreted by the president as an attempt to undermine his victory.

Kevin Carroll, a former CIA case officer, said, “It’s a very troubled relationship. Trump got it off to a terrible start with comments during the transition, comparing the intelligence community to the Nazis, and then his buffoonery in front of the memorial wall the day after he was inaugurated.”

On his first full day in office, Trump gave a speech at CIA headquarters. He stood on what CIA officers view as hallowed ground in front of a memorial to fallen agents where he launched an angry attack on the media and boasted about the size of his inaugural crowd.

It set the stage for a series of bitter public clashes, including an ongoing feud with President Barack Obama's CIA director, John Brennan, who, like Haspel, was a career CIA officer.

In Helsinki last year, Trump seemingly sided with Russian President Vladimir Putin and contradicted his intelligence agencies’ view on the election hacking, saying, "I don't see any reason why" Russia would have been involved.

This year, he contradicted evidence given by his intelligence chiefs that North Korea was unlikely to give up its nuclear weapons and that Iran was continuing to comply with the 2015 nuclear deal. “The intelligence people seem to be extremely passive and naive when it comes to the dangers of Iran,” he tweeted.

Glenn Carle, who spent 23 years with the CIA, said tensions were nothing new but had been taken to another level by a president who struggled to accept criticism. “The intel community — and the CIA in particular — is designed to be separate from the political process, with the mission of speaking truth to power, even if that is unpleasant,” he said. “So frequently, the chief executive will dislike the intelligence community. Who wants to have someone raining on your parade?”

Both Richard Nixon and Jimmy Carter had difficult relationships with the CIA. Subsequent chiefs worked to take their agencies out of the headlines and rebuild relations, according to Fleitz.

“Mike Pompeo and Gina Haspel, I think, really repaired the relationship and showed the president how incredibly valuable intelligence is and how they are really patriots working for him,” he said.

Haspel is not only well-liked in the agency but has developed a good working relationship with Trump, he added, based in part on Pompeo’s endorsement.

But members of the intelligence world now fear the fallout from the president’s violent reaction to the complaint about his phone call with the president of Ukraine. Carroll said members of the intelligence community took such language very personally.

....People, their VOTE, their Freedoms, their Second Amendment, Religion, Military, Border Wall, and their God-given rights as a Citizen of The United States of America! — Donald J. Trump (@realDonaldTrump) October 1, 2019

“It’s the sort of language that is thrown around on the far-right websites about the swamp, the elites, and the deep state, and now the most dangerous language which has been used now of treason and sabotage and coup d'état,” he said.

Haspel was unlikely to push back in support of her officer in public, he added. “I don’t know, and I shouldn’t know, and no one else should know what she may have said to him in private, but I would hope that she is sticking up for her officer,” he said.