NHS England is to appeal against a High Court ruling that it has the power to commission a drug described as a "game changer" in the fight against HIV/Aids - and could cost it £10-20 million a year.
The body argued that providing the drug - pre-exposure prophylaxis (PrEP) - was not its responsibility and it was for local councils to fund "preventative" health treatment.
But Mr Justice Green, sitting in London, disagreed and ruled that NHS England had erred in law and it did have the power to commission PrEP, a highly effective anti-retroviral drug used to stop HIV from becoming established in the event of transmission.
The ruling was a victory for leading charity National Aids Trust (NAT) with backing from the Local Government Association (LGA).
When taken consistently, PrEP has been shown to reduce the risk of HIV infection in people who are at high risk by more than 90%.
Allowing NAT's application for judicial review, the judge said on Tuesday the core of the legal challenge was about "the allocation of budgetary responsibility in the health field".
He said: "No one doubts that preventative medicine makes powerful sense. But one governmental body says it has no power to provide the service and local authorities say they have no money.
"The claimant is caught between the two and the potential victims of this disagreement are those who will contract HIV/Aids but who would not were the preventative policy to be fully implemented.
"In my judgment the answer to this conundrum is that NHS England has erred in deciding that it has no power to commission the preventative drugs in issue."
Alternatively, said the judge, NHS England has "mischaracterised the PrEP treatment as preventative when in law it is capable of amounting to treatment for a person with infection".
In any event NHS England had the power to commission preventative treatments because that facilitated, or was incidental to, "the discharge of its broader statutory functions".
Jonathan Fielden, NHS England's director of specialised commissioning and Deputy National Medical Director, said there would be an appeal against the conclusions reached by the judge as to the scope of NHS England's legal powers under the National Health Service Act 2006.
Fielden added: "In parallel with that we will set the ball rolling on consulting on PrEP so as to enable it to be assessed as part of the prioritisation round.
"Of course, this does not imply that PrEP - at what could be a cost of £10-20 million a year - would actually succeed as a candidate for funding when ranked against other interventions.
"But in those circumstances, Gilead - the pharmaceutical company marketing the PrEP drug Truvada - will be asked to submit better prices, which would clearly affect the likelihood that their drug could be commissioned."
Campaigners have said that while the majority of gay men use condoms to prevent being infected with HIV, there is also an "ethical duty" to provide PrEP to those who do not.
And they say the drug would provide an additional defence against HIV - and would not be used simply as an alternative to safe sex.
It comes after the results of a trial, published in February 2015, suggested that rates of HIV infection could be slashed by treating actively gay men with the anti-viral drug when they are healthy.
Michael Brady, medical director at the HIV/Aids charity Terrence Higgins Trust, welcomed the findings and described the drug as "a game-changer".
He said PrEP offered "another line of defence" against HIV, alongside condoms and regular testing.