WASHINGTON — In December 2005, Congress handed President George W. Bush a significant defeat by tightening legal restrictions against torture in a law called the Detainee Treatment Act. Soon afterward, Neil M. Gorsuch — then a top Justice Department official — sent an email to a White House colleague in case he needed “cheering up” about the administration’s setback.

The email from Judge Gorsuch, nominated by President Trump to fill the vacancy on the Supreme Court caused by the death of Justice Antonin Scalia, linked to articles about a less-noticed provision in the act that undercut the rights of Guantánamo Bay detainees by barring courts from hearing their habeas corpus lawsuits.

“The administration’s victory is not well known but its significance shouldn’t be understated,” wrote Judge Gorsuch, who had helped coordinate the Justice Department’s work with Congress on the bill.

The email about the court-stripping provision — which the Supreme Court later rejected — is among more than 150,000 pages of Bush-era Justice Department and White House documents involving Judge Gorsuch disclosed by the Trump administration ahead of his Senate confirmation hearings next week.