WASHINGTON — Attorney General Jeff Sessions late Friday night fired former FBI deputy director Andrew McCabe, a little more than 24 hours before McCabe was set to retire- a move that McCabe alleged was an attempt to slander him and undermine the ongoing special counsel investigation into the Trump campaign.

Sessions announced the decision in a statement just before 10 p.m., noting that both the Justice Department inspector general and the FBI office that handles discipline had found "that Mr. McCabe had made an unauthorized disclosure to the news media and lacked candor - including under oath - on multiple occasions."

He said based on those findings and the recommendation of the department's senior career official, "I have terminated the employment of Andrew McCabe effective immediately."

The move will likely cost McCabe a significant portion of his retirement benefits, though it is possible he could bring a legal challenge. He responded on Friday night with a lengthy statement, claiming he was being targeted because he was a witness in special counsel Robert Mueller III's probe into whether the Trump campaign coordinated with Russia, and asserting that his actions were appropriate. He also alleged former FBI Director James Comey knew about the media disclosure about which the inspector general has raised questions.

"This attack on my credibility is one part of a larger effort not just to slander me personally, but to taint the FBI, law enforcement, and intelligence professionals more generally," McCabe said. "It is part of this Administration's ongoing war on the FBI and the efforts of the Special Counsel investigation, which continue to this day. Their persistence in this campaign only highlights the importance of the Special Counsel's work."

President Donald Trump tweeted early Saturday morning, "Andrew McCabe FIRED, a great day for the hard working men and women of the FBI - A great day for Democracy. Sanctimonious James Comey was his boss and made McCabe look like a choirboy. He knew all about the lies and corruption going on at the highest levels of the FBI!"

An email notifying McCabe of the move was sent to his work account and his lawyers just minutes before Sessions's statement was made public, though McCabe learned of the firing from press accounts, his spokeswoman said. McCabe has been fighting vigorously to keep his job, and on Thursday, he spent nearly four hours inside the Justice Department pleading his case.

Michael Bromwich, McCabe's attorney, said that he had "never before seen the type of rush to judgment - and rush to summary punishment - that we have witnessed in this case." He cited in particular President Trump's attacks on McCabe on Twitter and the White House press secretary's comments about him on Thursday - which he said were "quite clearly designed to put inappropriate pressure on the Attorney General to act accordingly."

"This intervention by the White House in the DOJ disciplinary process is unprecedented, deeply unfair, and dangerous," Bromwich said.

McCabe has become a lightning rod in the political battles over the FBI's most high-profile cases, including the Russia investigation and the probe of Hillary Clinton's email practices. He has been a frequent target of criticism from Trump.

His firing - which was recommended by the FBI office that handles discipline - stems from a Justice Department inspector general investigation that found McCabe authorized the disclosure of sensitive information to the media about a Clinton-related case, then misled investigators about his actions in the matter, people familiar with the matter have said. He stepped down earlier this year from the No. 2 job in the bureau after FBI Director Christopher Wray was briefed on the inspector general's findings, though he technically was still an employee.

McCabe, who conducted interviews with several media outlets in advance of his firing but declined to do so with The Washington Post, said in his statement he was "being singled out and treated this way because of the role I played, the actions I took, and the events I witnessed" when the president fired Comey as FBI director. Mueller is looking at that termination as part of his examination into whether Trump was attempting to obstruct justice.

McCabe said in the statement that his testimony before the House Intelligence Committee - which he believed accelerated the process against him - revealed he "would corroborate" Comey's accounts of his interactions with Trump. Comey has said previously the president asked him for loyalty and, referring to the probe of the president's former national security adviser, asked if Comey would "let this go"

"The big picture," McCabe said, "is a tale of what can happen when law enforcement is politicized, public servants are attacked, and people who are supposed to cherish and protect our institutions become instruments for damaging those institutions and people."

Bromwich, himself a former Justice Department inspector general, suggested that office treated McCabe unfairly, cleaving from a larger investigation its findings on McCabe and not giving McCabe an adequate chance to respond to the allegations he faced. In his statement, Bromwich said McCabe and his lawyers were given limited access to the inspector general's draft report late last month, saw a final report and evidence a week ago and were "receiving relevant exculpatory evidence as recently as two days ago."

"With so much at stake, this process has fallen far short of what Mr. McCabe deserved," Bromwich said. "This concerted effort to accelerate the process in order to beat the ticking clock of his scheduled retirement violates any sense of decency and basic principles of fairness."

A spokesman for the inspector general's office declined to comment.

Some in the bureau might view McCabe's termination so close to retirement as an unnecessarily harsh and politically influenced punishment for a man who spent more than 20 years at the FBI. The White House had seemed to support such an outcome, though a spokeswoman said the decision was up to Sessions.

"We do think that it is well documented that he has had some very troubling behavior and by most accounts a bad actor," White House press secretary Sarah Huckabee Sanders said Thursday.

Trump and McCabe's relationship has long been fraught. The president has previously suggested that McCabe was biased in favor of Clinton, his political opponent, pointing out that McCabe's wife, who ran as a Democrat for a seat in the Virginia legislature, received hundreds of thousands of dollars in donations from the political action committee of Terry McAuliffe, then the state's governor and a noted Clinton ally. During an Oval office meeting in May, Trump is said to have asked McCabe whom he voted for in the presidential election and vented about the donations.

Justice Department Inspector General Michael Horowitz put McCabe in his crosshairs during a broad look at alleged improprieties in the handling of the Clinton email case. In the course of that review, Horowitz found that McCabe had authorized two FBI officials to talk to then-Wall Street Journal reporter Devlin Barrett for a story about the case and another investigation into Clinton's family foundation. Barrett now works for The Washington Post.

Background conversations with reporters are commonplace in Washington, though McCabe's authorizing such a talk was viewed as inappropriate because the matter being discussed was an ongoing criminal investigation. The story ultimately presented McCabe as a somewhat complicated figure - one who some FBI officials thought was standing in the way of the Clinton Foundation investigation, but who also seemed to be pushing back against Justice Department officials who did not believe there was a case to be made.

McCabe said in his statement that he, as the FBI's deputy director, had the authority to do what he did. He said he was simply trying to "set the record straight" and "make clear that we were continuing an investigation that people in DOJ opposed" after the bureau was "portrayed as caving under that pressure, and making decisions for political rather than law enforcement purposes."

"It was not a secret, it took place over several days, and others, including the Director, were aware of the interaction with the reporter," he said. "It was the type of exchange with the media that the Deputy Director oversees several times per week. In fact, it was the same type of work that I continued to do under Director Wray, at his request."

In an interview with CNN, McCabe alleged that in December, he had a "long conversation with the editor of a major national newspaper at Chris Wray's request, and engaged with this editor in an effort to get them to back off a story that we thought would be harmful to our operational equities."

An FBI spokesman and a lawyer for Comey declined to comment. McCabe also said he answered questions about the matter "truthfully and as accurately as I could amidst the chaos that surrounded me," acknowledging only that he had clarified his account.

"And when I thought my answers were misunderstood, I contacted investigators to correct them," he said.

McCabe, who turns 50 on Sunday and would have then been eligible for his full retirement benefits, had quickly ascended through senior roles to the No. 2 leadership post. He briefly served in an interim capacity as the FBI director, in the months between when Trump fired Comey from the post and Wray was confirmed by the Senate.

McCabe's team on Friday night released a bevy of statements from former national security officials supporting the former deputy director, including from former Director of National Intelligence James Clapper Jr.; former National Security Agency Deputy Director Richard Ledgett Jr.; former U.S. attorney Chuck Rosenberg; former FBI national security official Michael Steinbach; and former Justice Department national security official Mary McCord.

Steinbach said McCabe had "become a convenient scapegoat so that narrow political objectives can be achieved." McCord said she "never doubted his honesty or motivations, and can say without hesitation that he was one of the finest FBI agents with whom I ever worked." Notably absent was a statement from Comey, McCabe's former boss, though Comey did say after McCabe stepped down as deputy director that he "stood tall over the last 8 months, when small people were trying to tear down an institution we all depend on."

Comey is still considered a key subject in Horowitz's probe of how the FBI handled the Clinton email case.