WASHINGTON (AP) — Former FBI Director James Comey has reached a deal to testify privately to the House Judiciary Committee, backing off his legal fight for an open hearing, his attorney said Sunday.

Comey, whose lawyers went to court to challenge a congressional subpoena, said in a tweet that it was "hard to protect my rights without being in contempt."

As part of a deal with legislators, Comey has been told that he is free to speak about the questioning afterward and that a transcript would be released 24 hours after he testifies, his attorney, David Kelley, said.

Comey's lawyers told a federal judge on Friday that the interview should be done in a public setting because they fear that statements from a closed-door interview would be selectively leaked. A lawyer for Congress, however, argued that committees can conduct investigations however they please and Comey had no right to refuse a subpoena or demand a public hearing.

Comey is expected to be questioned about decisions made by the FBI in 2016, including a call not to recommend criminal charges against Democrat Hillary Clinton for her use of a private email server and the FBI's investigation into potential coordination between Russia and Republican Donald Trump's campaign. Trump fired Comey in May 2017.

The interview is scheduled for Friday and Comey will be "free to make any or all of that transcript public as he is free to share with the public any of the questions asked and testimony given during the interview," Kelley said.

Because of the deal, Comey has agreed to withdraw his challenge to the subpoena. A judge had been set to rule on the matter on Monday.