Shaker Aamer was captured by Afghan villagers in 2001
Lawyers for the last recognised British resident in Guantanamo Bay can see papers they believe could help free him, the High Court has ruled.
Saudi-born Shaker Aamer, who has four British children, has been held in Guantanamo for seven years.
His lawyers say government documents contain evidence that confessions he made were obtained through torture.
But ministers are now likely to block disclosure on public interest grounds, meaning Mr Aamer faces a new battle.
His lawyers told the High Court in London on Tuesday that the government documents he was seeking included evidence that British intelligence officers were present on at least two occasions when he was tortured, but they did not assist him.
Richard Hermer QC said Mr Aamer's legal team urgently needed to see the material, as his case was currently being reviewed by the Guantanamo detainee review task force set up by US President Barack Obama.
A decision on whether Mr Aamer is to be released is expected by mid-January.
Lord Justice Sullivan and Mr Justice Lloyd Jones rejected government arguments that Mr Aamer was not entitled to disclosure.
Lord Justice Sullivan said the matter was "clearly very urgent".
He added: "If this information is to be of any use it has to be put in the claimant's hands as soon as possible."
Mr Aamer, 42, is classed as a permanent UK resident. He is married to a British national and was living with their four children in London.
His solicitor, Irene Nembhard, said: "It is the first ray of light for Shaker and his family.
"His family will be overjoyed and they will be expecting that at this point the British government will give their lawyers their documents to assist them in persuading the Americans to release Shaker back to the UK and to them."
But in court, government lawyers made it clear a public interest immunity certificate would be issued to block disclosure on the grounds that it would be damaging to the public interest.
That will mean Mr Aamer's legal team will have to take further court action to challenge the certificate.
At the hearing, Mr Hermer described how Mr Aamer had been detained at the US-run detention centre in Cuba since February 2002.
Before that he was held at Bagram airport in Afghanistan, following his capture by Afghan villagers in December 2001.
At Bagram he was subjected to torture during interrogations, the judges were told.
On one occasion this involved "having his head repeatedly banged so hard against a wall that it bounced".
During that interrogation an MI5 officer was present, said Mr Hermer, who added that Mr Aamer had also been threatened with death during an interrogation at which an MI5 officer was present.
A government spokesman said it was "disappointed" by the ruling, and that the documents were not necessary to support the US review of his case.
"We have already provided all the relevant information held on Mr Aamer by the UK to the US Review Panel, which is coordinated by the US Attorney General and which is considering his case, along with those of more than 200 others held in Guantanamo.
"We will continue to argue strongly the point of principle involved in this case - that it is fundamental to the national interest of the United Kingdom that our intelligence and security services are able to operate without fear of having to disclose secret intelligence material."
He added that "strenuous efforts" had already been made on Mr Aamer's behalf.
"The decision on his future is entirely one for the United States, but the US authorities know well our outstanding request for his release and our offer to see him returned to the UK."