A drug that dramatically reduces the risk of being infected with HIV will now be given to patients by the NHS in England.
The health service lost a court battle in the summer after arguing responsibility for paying for it should fall to local authorities not the NHS.
Now at least 10,000 people will be given the "Prep" drug in a three-year-long clinical trial.
NHS England says this will help them understand how to offer it more widely.
Pre-exposure prophylaxis or Prep is a daily pill that disables HIV before it gets a stranglehold in the body.
It costs £400 a month per person and trials suggest it can cut the risk of being infected by up to 86%.
NHS England, which fought not to offer the drug, said in a statement there was "strong" evidence that it was effective.
However, it said there were still questions to be answered about how it is used on a wide scale across England.
Its trial on at least 10,000 people will try to figure out how to get the drugs to the right people, how popular it would be and for how long they would take Prep.
Dr Ian Williams, chairman of NHS England's group on HIV, said: "This announcement demonstrates NHS England's commitment to fund Prep and provides the chance to best prepare England for optimal roll-out following this large-scale clinical trial.
"For now, the trial will provide access to Prep for thousands of people most at risk of acquiring HIV."
Men who have sex with men are one of the groups at the highest risk of contracting HIV.
In London, one in eight gay men has HIV, while the proportion in the rest of the UK is one in 26.
'This is about saving lives'
Harry Dodd, 25, is one of about 500 homosexual men in England who are taking Prep as part of a trial called Proud.
He says: "I've seen the panic on the face of previous boyfriends when they are awaiting their [HIV test] results - it's a huge fear and it affects everything you do.
"To be able to have sex without having that fear hanging over you all the time is huge."
Harry says taking Prep has still not become socially acceptable.
"Too many people seem to think it will encourage a hedonistic lifestyle, but for me this is about saving lives," he says.
"People reacted with cynicism when the contraceptive pill for women was first introduced.
"For me, taking Prep has helped me to trust again, have relationships and build bridges and that shouldn't be taken away."
Dr Michael Brady, medical director of the Terrence Higgins Trust, said the evidence on Prep was "overwhelming" but the new trial could help understand how it will work in real life.
He added: "However, we do still need answers to many questions about the trial, in terms of how exactly the trial will work in practice, how those at risk will be able to access Prep, no matter where they live, and what will happen after the trial."
Deborah Gold, chief executive of the National Aids Trust, said: "We are absolutely delighted that following our wins in court, NHS England, working with Public Health England and local government, will be now making Prep available on a large scale, and quickly, to those who need it."
The NHS in Wales, Scotland and Northern Ireland have not yet made a decision on Prep.
Follow James on Twitter.