Former FBI Director James Comey has filed a lawsuit in federal court in Washington fighting a subpoena from the House Judiciary Committee to testify in a closed-door session.

Comey was served a subpoena from Chairman Bob Goodlatte, R-Va., last week and said he would only testify if the hearing was public.

In the 17-page motion filed in U.S. District Court for the District of Columbia late Thursday, a lawyer for Comey says the closed-door deposition “exceeds a proper legislative purpose, is issued in violation of House rules, and unduly prejudices and harasses the witness.”

The House Judiciary Committee, alongside the House Oversight Committee, has been conducting a joint investigation into the Justice Department and FBI’s actions ahead of the 2016 presidential election. This includes the probe into former Secretary of State Hillary Clinton’s use of a private email server.

The chairmen of both committees wrote a letter to Comey on Sept. 21 requesting he appear voluntarily for a closed-door interview, to which Comey said in a letter on Oct. 1 that he would decline the invitation.

According to the motion filed Thursday, Comey did not hear from the committees until the subpoena to appear was issued on Nov. 21.

Comey's testimony "will be subject to selective leaking by members of the Judiciary Committee in furtherance of the Committee's abuse of these proceedings and harassment of witnesses who appear in closed-door depositions,” wrote his lawyer, Vincent Cohen.

“Mr. Comey asks this Court’s intervention not to avoid giving testimony but to prevent the [two committees] from using the pert of a closed interview to peddle a distorted, partisan political narrative about the Clinton and Russian investigations through selective leaks,” Cohen wrote.

Comey, who has traded public barbs with not just President Trump, but also congressional Republicans, was fired suddenly in May 2017.