Ackroyd’s victory came after a six-year legal battle with the Mersey Care NHS Trust.

Mr Justice Tugendhat said that Ackroyd was a "responsible journalist whose purpose was to act in the public interest". He confirmed that there is "a vital public interest" in the protection of a journalist’s sources.

Today’s decision was the latest in a case which has been rumbling through the courts for years.

Ackroyd gave extracts from Brady’s medical records to the Daily Mirror, which printed them in an article in December 1999. The story quoted from confidential patient records following the killer’s hunger-strike.

The Trust attempted to force the MGN to reveal the source of the leaked medical records. The newspaper fought the case all the way to an unsuccessful appeal to the House of Lords. When the Mirror met with final defeat, Ackroyd stepped forward to reveal that he had provided the story for £1,250.

When Ackroyd came forward, the Ashworth secure hospital launched legal proceedings against him to reveal his source.

The case resulted in a clash between the competing interests of a journalist’s right to protect his source and the hospital’s right to keep its medical records confidential. Lawyers had argued that if Ackroyd were ordered to reveal his sources, it would amount to a breach of his human right to freedom of expression. The Trust argued that its need to protect medical records overrides the right of freedom of expression.

Today’s High Court ruling confirms that someone trying to get a journalist to reveal their source must prove a "pressing social need" for the source to be disclosed. After the Human Rights Act that includes a rigorous analysis of all the circumstances of the case. The court said that one of these is the public interest in protecting a journalist’s sources.

"[The defendant] has a record of investigative journalism which has been authoritatively recognised, so that it would not be in the public interest that his sources should be discouraged from speaking to him where it is appropriate that they do so," the judge said.

The judge, who also awarded Ackroyd his legal costs, said: "Considering the facts as I now do in January 2006, in my judgment it has not been convincingly established that there is today pressing social need that the sources should be identified.

"An order for disclosure of the defendant’s sources would not be proportionate to the pursuit of the hospital’s legitimate aim to seek redress against the source, given the vital public interest in the protection of a journalist’s source," he said.

In his ruling, Mr Justice Tugendhat acknowledged that he had reached the opposite conclusion to that of the House of Lords in the original MGN action, but stressed that this was because the facts of this case were different and "not because I have considered that medical records are less private or confidential, or less deserving of protection, than those Courts held."

Mr Justice Tugendhat said his stance was partly due to the new evidence that he heard, and partly due to changed circumstances since the first case began in 1999:

"They include that the hospital no longer contends that the source acted for money, with the result that I have had to find afresh what the purpose of the source was, and to re-assess the risk of further disclosures now, in the light of that fact, and in the light of the absence of any similar disclosures since 1999.

"The extent of the disclosure by the source was more limited than was previously understood to be the case. I have not found that the source was one of a number of people limited to 200, but that it is impossible to say how large the group is. I have not found that the source was probably an employee, although he or she may have been, and even if it was an employee, the numbers who have left the hospital since 1999 represent about a third of those who worked there in 1999.

"So the likelihood of the hospital being able to obain the redress it seeks against the source is correspondingly diminished. In addition, the stance of Ian Brady has changed, and I have not found that the disclosure was made without his consent.

"Finally, unlike the courts in the MGN action, I have heard the evidence of Mr Ackroyd and have concluded that he was a responsible journalist whose purpose was to act in the public interest."

Ackroyd was represented by the NUJ’s lawyers, Thompsons.

NUJ general secretary Jeremy Dear said: "This is a fantastic result for Robin and for all journalists. The fundamental point of principle – that there is a strong public interest in upholding journalists’ right not to reveal their sources – has been maintained.

"Robin has showed huge courage in standing true to this principle during six very difficult years. We all owe him an immense debt of gratitude – all journalists are in a stronger and safer position because of the brave stand he has taken."

During the latest court hearing, Ackroyd had told the judge that he one of the purposes of the six-year legal battle waged by the Trust could well be partly motivated by a wish to wreck his career.

Speaking outside the court, Ackroyd said the personal cost of his six-year battle to protect his sources had been high. It started when he was 32 and he is now 39. "I’ve read Kafka, I really need to get a copy of Bleak House," he said.

However, today’s ruling is unlikely to be the end of the matter. The judge gave the Trust leave to appeal on the basis of argument by its lawyers it had "a real prospect of success."

Ackroyd said his priority now is to finish writing a book about his travels in Mongolia.