Former FBI deputy director fired just days before retirement to kick in Andrew McCabe, the former deputy director of the FBI, was set to retire Sunday.

Former FBI deputy director Andy McCabe was fired Friday from the federal government, just two days before he was set to retire, Attorney General Jeff Sessions announced in a statement late Friday night.

Nearly 24 hours earlier, McCabe was inside the Justice Department making the case to keep his job until Sunday when he officially qualifies for retirement benefits. His firing means his full pension -- built after nearly 22 years in government -- is in jeopardy.

President Donald Trump ripped McCabe on Twitter around midnight hours after McCabe was fired. Trump twice called it a "great day" and said McCabe was worse than regular Trump target, James Comey, the former FBI director fired by Trump last May.

In his statement Sessions said: "After an extensive and fair investigation and according to Department of Justice procedure, the Department’s Office of the Inspector General (OIG) provided its report on allegations of misconduct by Andrew McCabe to the FBI’s Office of Professional Responsibility (OPR)."

"The FBI’s OPR then reviewed the report and underlying documents and issued a disciplinary proposal recommending the dismissal of Mr. McCabe. Both the OIG and FBI OPR reports concluded that Mr. McCabe had made an unauthorized disclosure to the news media and lacked candor -- including under oath -- on multiple occasions," the statement continued.

"The FBI expects every employee to adhere to the highest standards of honesty, integrity, and accountability. As the OPR proposal stated, “all FBI employees know that lacking candor under oath results in dismissal and that our integrity is our brand,” Sessions said.

"Pursuant to Department Order 1202, and based on the report of the Inspector General, the findings of the FBI Office of Professional Responsibility, and the recommendation of the Department’s senior career official, I have terminated the employment of Andrew McCabe effective immediately," the Sessions statement said.

McCabe issued his own statement saying he would no longer keep silent.

"For the last year and a half, my family and I have been the targets of an unrelenting assault on our reputation and my service to this country. Articles too numerous to count have leveled every sort of false, defamatory and degrading allegation against us. The President’s tweets have amplified and exacerbated it all. He called for my firing. He called for me to be stripped of my pension after more than 20 years of service. And all along we have said nothing, never wanting to distract from the mission of the FBI by addressing the lies told and repeated about us."

"No more," McCabe said.

Later in his statement, McCabe accused the president of driving an effort to destroy his reputation and hurt special counsel Robert Mueller's investigation.

"Here is the reality: I am being singled out and treated this way because of the role I played, the actions I took, and the events I witnessed in the aftermath of the firing of James Comey. The release of this report was accelerated only after my testimony to the House Intelligence Committee revealed that I would corroborate former Director Comey’s accounts of his discussions with the President," the statement said.

"The OIG’s focus on me and this report became a part of an unprecedented effort by the Administration, driven by the President himself, to remove me from my position, destroy my reputation, and possibly strip me of a pension that I worked 21 years to earn. The accelerated release of the report, and the punitive actions taken in response, make sense only when viewed through this lens. Thursday’s comments from the White House are just the latest example of this," McCabe said.

"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's statement continued. "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."

Friday's move by Sessions comes after FBI officials concluded McCabe should be fired for allegedly misleading internal investigators about his role two years ago in allowing an FBI spokesman and FBI attorney to disclose information about the agency's Clinton Foundation investigation to a reporter.

On Thursday, press secretary Sarah Sanders said McCabe's "troubling behavior" was "well-documented," insisting McCabe was "by most accounts a bad actor."

McCabe, however, has denied any wrongdoing.

“I have tried at every juncture to be as accurate and of course truthful in all of my encounters with whoever was interested in asking questions,” McCabe recently told ABC News. “The idea of being condemned or miscast in any way contrary to that is just unbelievably disappointing and really offensive to me.”

After McCabe was questioned by investigators, he said he realized he needed to clarify some of his responses, so he “proactively reached out to those people to ensure that they clearly understood what my position was." He would not offer any further details.

The FBI’s Office of Professional Responsibility recommended that McCabe be fired after an internal report by the Justice Department’s inspector general accused the FBI veteran of misleading investigators looking into how FBI and Justice Department officials handled an array of matters connected to the 2016 presidential campaign, a source briefed on the recommendation told ABC News.

Because the inspector general’s report has not been released publicly yet, it’s still unclear exactly why investigators believe McCabe was not forthcoming, or if McCabe is criticized for other actions. ABC News has not reviewed the report.

Over the past year, McCabe has become a frequent target of criticism from Trump and Republican lawmakers, who allege that McCabe’s time at the top of the FBI was emblematic of political bias in the FBI’s law enforcement work.

In 2015, while McCabe was head of the FBI's Washington Field Office, his wife ran for state senate in Virginia as a Democrat. She lost the election in November 2015, and three months later McCabe became deputy director, giving him an oversight role in the investigation of Hillary Clinton’s use of a private email server as secretary of state.

In October 2016, the Wall Street Journal published at least one article that questioned whether McCabe was hampering the federal probe of the Clinton Foundation.

According to McCabe, he was trying to push the probe forward while the Justice Department tried to slow it.

“I had not slowed our efforts, but it was part of the same theme: ‘I was maybe politically motivated, and worse, that the FBI was being subjected to influence,’” McCabe said. “I just thought that was incredibly damaging to the FBI."

Ahead of the story’s publication, McCabe authorized an FBI spokesman to speak with the Wall Street Journal about efforts to keep the Clinton Foundation investigation moving forward, McCabe told ABC News. As the number-two at the FBI, McCabe has authority to approve such a disclosure, McCabe said.

After the Wall Street Journal story was published, McCabe recused himself from the Clinton matter.

McCabe first joined the FBI in 1996, investigating organized crime cases in New York. Over the next several years, he shifted his focus to rooting out international terrorists, and in 2012 he became the head of the FBI’s counterterrorism division at headquarters in Washington.

In October 2013, McCabe took over the FBI’s entire national security branch, and the next year he moved to become the assistant director in charge of the FBI’s Washington Field Office.