A federal judge said he was "shocked" to find out that longtime Hillary Clinton aide Cheryl Mills had been granted immunity from the Justice Department during the FBI investigation of Hillary Clinton's server.

During a hearing in D.C. on Friday, U.S. District Court Judge Royce Lamberth made the comment about Mills, Clinton's former chief of staff, during his opening remarks, referring to when he read the DOJ inspector general report.

"I had myself found that Cheryl Mills had committed perjury and lied under oath in a published opinion I had issued in a Judicial Watch case where I found her unworthy of belief, and I was quite shocked to find out she had been given immunity in — by the Justice Department in the Hillary Clinton email case," Lamberth said. "So I did not know that until I read the IG report and learned that and that she had accompanied the Secretary to her interview."

The FBI determined Clinton and her staff exhibited "extreme carelessness" by sharing classified information on an unsecured private server that was kept in Clinton's basement. Other individuals with ties to Clinton also received immunity deals over the course of the investigation.

The hearing Monday was the latest development in conservative watchdog Judicial Watch's lawsuit, filed against the State Department in July 2014, after it failed to respond to a FOIA request. The lawsuit relates the Sept. 11, 2012 attack on the U.S. consulate in Benghazi, Libya, which shined light on Clinton's email server.

Lamberth ordered the hearing due to a request by Judicial Watch for testimony under oath from Clinton, Mills, and other State Department officials on the FOIA and emails matters. Judicial Watch announced what had been said during the hearing in a press release Wednesday.

In a statement, Judicial Watch President Tom Fitton said, “President Trump should ask why his State Department is still refusing to answer basic questions about the Clinton email scandal."

During the 2016 election cycle, Trump's campaign said Clinton undoubtedly ran a "criminal scheme" at the State Department after it was reported that Mills and others got immunity.

Lamberth previously has been critical of Mills. Back in a 2008 opinion, Lamberth described Mills’ conduct in handling a separate email controversy as an official in the Bill Clinton White House official as "loathsome."