Former Deputy Attorney General Rod Rosenstein said he made the decision to release to the media text messages between two FBI employees who criticized President Trump during the 2016 presidential election.

Rosenstein said in a court filing late Friday that he made the call in part to protect the FBI from selective leaks by Congress.

FBI agent Peter Strzok and FBI attorney Lisa Page, who were having an affair, disparaged Trump in their exchanges and tried to reassure one another that he couldn’t be elected. The two also discussed an “insurance policy” to prevent Trump’s win. Trump and his supporters have used the messages to argue that there were efforts to prevent him from taking office, but Strzok and Page denied their messages were anything other than venting.

Both Page and Strzok are suing over the release, saying it invaded their privacy.

Until Friday, it was unclear who had authorized the release of hundreds of their text messages to journalists in December 2017.

Rosenstein said he approved the disclosure because he was set to testify to the House Judiciary Committee the next day and the release of the text messages by members of Congress, who had requested the messages, was inevitable.

“Some congressional members and staff were expected to release them intermittently before, during, and after the hearing, exacerbating the adverse publicity for Mr. Strzok, Ms. Page, and the Department. The disclosure obviously would adversely affect public confidence in the FBI, but providing the most egregious messages in one package would avoid the additional harm of prolonged selective disclosures and minimize the appearance of the Department concealing information that was embarrassing to the FBI,” Rosenstein wrote in a five-page statement signed Friday.

“With the express understanding that it would not violate the Privacy Act and that the text messages would become public by the next day in any event, I authorized [the Department of Justice’s Office of Public Affairs] to disclose to the news media the text messages that were being disclosed to congressional committees,” Rosenstein added.

Ex-special counsel Robert Mueller removed Strzok from his role on the Russia investigation after learning about the text messages in the summer of 2017. Page, who had been involved in the earlier stages of the investigation, was already working on another assignment.

The FBI fired Strzok in 2018, and Page resigned from the bureau. Strzok is also challenging his firing, arguing that he was terminated because of political pressure from Trump.