The Justice Department has told former FBI Deputy Director Andrew McCabe it isn't prosecuting him and it considers the matter 'closed' – despite the president's string of furious tweets about McCabe and a judge's warning the a prolonged investigation had a whiff of retribution.

Federal prosecutors closed an investigation into whether McCabe lied to federal officials about his involvement in a news media disclosure, McCabe's legal team said Friday.

The end of the two-year probe of McCabe came just hours before it was revealed a federal judge scolded prosecutors and flagged President Trump's repeated tweets on the case as being like a 'banana republic.'

U.S. District Court Judge Reggie Barnett Walton made the comment as he heard a Freedom of Information Act lawsuit in relation to the case.

'The public is listening to what's going on, and I don't think people like the fact that you've got somebody at the top basically trying to dictate whether somebody should be prosecuted,' Walton, a George W. Bush appointee, told prosecutors in September.

'I just think it's a banana republic when we go down that road and we have those type of statements being made that are conceivably—even if not—influencing the ultimate decision,' he lectured. 'I think there are a lot of people on the outside who perceive that there is undue, inappropriate pressure being brought to bear.'

Citizens for Responsibility and Ethics in Washington, which sued for court transcripts, said it was 'not surprising' that the government announced it was dropping the case as the transcripts were ordered released, the Daily Beast reported.

The decision not to charge McCabe revolves a criminal investigation that spanned more than a year and began with a referral from the Justice Department's inspector general, which said McCabe repeatedly lied about having authorized a subordinate share information with a newspaper reporter for a 2016 article about an FBI investigation into the Clinton Foundation.

The IG found McCabe 'lacked candor' on multiple occasions during a leak investigation.

McCabe's lawyers said in a statement they were told in a phone call and letter that the case is closed and 'no charges will be brought against him based on the facts.'

In the clear: In a letter on Friday, prosecutors told McCabe´s lawyers that they decided 'not to pursue criminal charges against your client' after careful consideration.

President Trump responded to Attorney General William Barr's statements by asserting his 'legal right' to intervene in criminal case

President Trump said he had the 'legal right' to intervene in criminal cases 'but I have so far chosen not to!' That was just over 12 hours after Bill Barr told ABC News he wanted the president to 'stop the tweeting'

McCabe, a frequent target of attacks from President Donald Trump, has denied that he intentionally misled anyone. He has said his 2018 firing - for what the Justice Department called 'lack of candor' - was politically motivated. He sued the Justice Department in August, saying officials had used the inspector general´s conclusions as a pretext to rid the FBI of leaders Trump perceived as biased against him.

In a letter on Friday, prosecutors told McCabe's lawyers that they decided 'not to pursue criminal charges against your client' after careful consideration.

'Based on the totality of the circumstances and all of the information known to the government at this time, we consider the matter closed,' said the letter, signed by the chief of the U.S. attorney's office's public corruption unit.

McCabe cheered the outcome but blasted prosecutors for taking two years to resolve his case in an interview with CNN, where he is a contributor. He called it a 'disgrace'

The Justice Department wrote McCabe's lawyer to tell him they consider the matter 'closed'

The decision was announced hours after Trump slapped back at Bill Barr, asserting the 'legal right' to intervene in criminal cases, just over 12 hours after his attorney general warned him his tweets and comments made it difficult to do his job.

Trump's pushback, which he issued publicly on Twitter, capped off a week of extraordinary statements about the criminal case of longtime advisor Roger Stone, who was convicted of witness tampering and lying to Congress about contacts with WikiLeaks.

Trump began by quoting from Barr's extraordinary interview with ABC News, where he said: 'The President has never asked me to do anything in a criminal case.

Then he added: 'This doesn't mean that I do not have, as President, the legal right to do so, I do, but I have so far chosen not to!'

'I think it's time to stop the tweeting about Department of Justice criminal cases,' Barr had told ABC News on Thursday afternoon.

'I cannot do my job here at the department with a constant background commentary that undercuts me.'

McCabe is among a clutch of top former FBI officials who have been the focus of the president's rage.

This week while venting about the Roger Stone case for what he called mistreatment, Trump fumed at the failure to charge former FBI director James Comey.

Trump wanted McCabe to get charged after the release of the damning inspector general's report. He was also set off by two other prosecutorial decisions, the Washington Post reported – the decision by prosecutors to seek jail time for former National Security Advisor Mike Flynn after he changed his legal posture and started going after the government, and the decision by U.S. Attorney John Huber not to bring charges against Hillary Clinton after reviewing the long history of her email controversy.

Trump famously let cheering crowds calling to 'lock her up' during the 2016 campaign.

McCain has been a regular subject of Trump's Twitter attacks. In late January, he retweeted a post about the Justice Department's response to McCabe's lawsuit. McCabe argues the FBI engaged in retaliation after the IG report.

Trump last year linked McCabe to his favorite target, former FBI Director James Comey

Trump retweeted Kellyanne Conway who had tagged an article accusing McCabe of 'lying nad leaks'

In November, Trump railed against McCabe and other officials after he complained about a jury's conviction of Roger Stone and prosecutors' push for jail time

Days earlier, he retweeted counselor to the president Kellyanne Conway, who tagged a Wall Street Journal opinion piece that said the FBI was a 'leakfest' and that 'Andy McCabe lost his job & part of his pension for lying about leaks.'

Trump's constant commentary on the case could have furnished McCabe's lawyers that he was being singled out for political prosecution had charges been brought.

Trump tweeted in November: 'So they now convict Roger Stone of lying and want to jail him for many years to come. Well, what about Crooked Hillary, Comey, Strzok, Page, McCabe, Brennan, Clapper, Shifty Schiff, Ohr & Nellie, Steele & all of the others, including even Mueller himself? Didn't they lie?'

The IG found that McCabe 'lacked candor, including under oath, on multiple occasions in connection with describing his role in connection with a disclosure' to a Wall Street Journal reporter and that his 'disclosure of the existence of an ongoing investigation in the manner described in this report violated the FBI's and the Department's media policy and constituted misconduct.

In just the latest sign of the rough waters Barr is seeking to navigate, he assigned an outside prosecutor to review the case against Flynn, the New York Times reported. Flynn cooperated for many hours with investigators and pleaded guilty to lying to the FBI – then sought to withdraw his plea and accused the government of misconduct, a charge a federal judge rejected.

McCabe took a victory lap on CNN, where he is a contributor.

'It is an absolute disgrace that they took two years and put my family through this experience for two years before they finally drew the obvious conclusion and one they could have drawn a long, long time ago,' he said.

He linked his case to that of Roger Stone, and raised concerns about political pressure to punish Trump's enemies and go easier on his friends, what he termed the 'politicization of investigations.'

'We were getting more and more concerned about where this would end up,' McCabe said. 'We are seeing things happen every day in this country that many of us never thought we'd see here.'