Image copyright AP Image caption Donald Trump and US spies have disagreed openly on hacking during the US election

It is not unprecedented for political leaders to fall-out with spies. But a row has never before played out so publicly - with rival pronouncements over Twitter and in front of Congress.

Two competing forces are clashing. First, the intelligence community's credibility, which has been called into question by President-elect Donald Trump.

And second, the legitimacy of Mr Trump's presidency, called into question by the intelligence community's conclusion that the Kremlin sought to support his election.

Neither side is likely to back off and both may come out damaged.

Relations between political leaders and intelligence officials have always had their ups and downs.

In the late 1970s, after a series of Congressional committees raised fears of the CIA having got out of control, President Carter brought in a new director, Stansfield Turner, who cleared out the agency of many of its staff leading to much unhappiness.

Image copyright @realDonaldTrump

CIA Director James Woolsey did not so much have a bad relationship as no relationship at all with Bill Clinton, to the extent that when a small aircraft crashed on the White House lawn, the joke was that it was Mr Woolsey trying to get a meeting with the president.

Under George W Bush, there was real tension, especially in the aftermath of the intelligence community's failure over Iraq's weapons of mass destruction and on briefings about the future of Iraq.

President Bush appointed Republican Congressman Porter Goss to try and align the agency more closely with the White House.

But the result was a disastrous falling out between Mr Goss's senior staff and top officials at the CIA. Goss only lasted a year.

It is a precedent that incoming CIA Director - another Republic Congressman, Mike Pompeo - will only be too aware of as he prepares to take the helm.

One thing that has been notable is that since his nomination he has offered very little public comment.

On the whole, those close to the CIA have suggested officials there are less worried by his nomination than that of other officials like incoming National Security Advisor Michael Flynn.

He is reported to have a degree of animosity towards the CIA and the Directorate of National Intelligence (which plays an over-arching role) after his stint running the Defence Intelligence Agency.

Media playback is unsupported on your device Media caption CIA director John Brennan tells the BBC what global threats Donald Trump will face as US president

There are reports that the Trump team may also push through reforms of the intelligence community - which might be seen by some insiders as a veiled threat.

This could aim to reduce the role of Director of National Intelligence and could also push the CIA towards a different operational stance.

The CIA has just undergone a major re-organisation under John Brennan.

In an interview in November, Mr Brennan told me he would be highlighting to his successor the importance of modernisation and also ensuring the most diverse possible workforce.

He also confessed that while he was hopeful he would get the chance to advise the incoming team on how to best employ the range of covert capabilities that the CIA has its disposal - which include drone strikes - he did not know how far the new team would take that advice on board.

A new world?

Staff at the agencies will be wondering what policies they will be expected to carry out.

Donald Trump talked of a return to waterboarding during the campaign.

The legacy of the use of such techniques during the Bush years continues to be highly sensitive within the agency with battles in the Obama administration over how far to distance itself from the agency's past.

The NSA, which has also undergone a bruising internal reform process, may also be worried.

After the trauma of the Snowden revelations and the subsequent emphasis on not being a 'rogue agency', and on compliance, there may now be concerns over whether a new president may deploy its powerful capabilities in a way which might, if it became public, be highly controversial.

Image copyright AP Image caption The CIA under President Barack Obama has tried to distance itself from its less salubrious past

The intelligence community has historically gone through cycles in which first a president pushes for controversial covert action, be it assassination plots, domestic intelligence collection or waterboarding.

But then after it is revealed, there is a swing of the pendulum the other way by a new administration, often leaving officers feeling exposed for past actions.

They may be wondering whether the pendulum is about to swing again. But in the Trump era they also may be wondering whether something different is about to happen.

When weapons of mass destruction were not found in Iraq, spies and politicians in London and Washington engaged in an uneasy truce.

Both sides realised they had been complicit in the presentation of intelligence to the public which proved wrong and that if they turned on each other in a blame game, it would be bloody, vicious and self-destructive.

Image copyright Reuters Image caption Mr Trump plays by different rules to previous US leaders

But in this current stand-off, the situation is different, not least because we are at a moment of transition and the current intelligence officials are on their way out and may feel they have little to lose by speaking out.

Donald Trump also plays by different rules.

But the result is that if a public spat continues and even escalates, both the intelligence community and the incoming political leadership could emerge damaged.

And the only people who will be smiling will be America's adversaries