Rishi Sunak has apologised for the treatment of LGBT veterans after they were sacked or forced out of the military for being gay.
The UK PM said the ban was an "appalling failure" of the British state.
It was illegal to be gay in the British military until 2000 - with thousands of veterans thought to be affected.
It comes after a long-awaited report into their treatment was published on Wednesday.
Addressing MPs in parliament, the prime minister said: "Many endured the most horrific sex abuse and violence, homophobic bullying and harassment all while bravely serving this country.
"Today on behalf of the British state I apologise."
Emma Riley, 51, was a Royal Navy radio operator for three years before she was arrested and discharged for being a lesbian after telling a colleague her sexuality in the early 1990s.
She told the BBC that she welcomed the report, and that she hoped it would be put into place "swiftly."
"Having our history, experiences and enormous pain acknowledged and apologised for, hearing that the Armed Services and government that perpetuated institutional bullying will now be held accountable to finally support LBGT+ Veterans, is a relief," she said.
Veterans have previously told the BBC how their lives were devastated by the ban.
Carol Morgan, who was dismissed after telling her bosses she was gay in 1978, kept her sexuality secret for another 30 years and said she had been "robbed" of her life.
Ken Wright, 62, served as an RAF Police Officer before losing his job when his bosses found out he was gay.
He described how losing his position in the military had left him feeling as though "his country didn't want him."
He added: "After being denied the opportunity to defend one's country, being told you aren't good enough to wear the uniform, it takes huge inner strength to feel reconciled all of a sudden today.
"Carrying that insult for 35 years scars you for life."
The report says many faced invasive medical examinations, intrusive police investigations and in some cases, as recently as 1996, were sent to prison for their sexuality. Many still have a criminal record to this day.
It also details how some veterans faced a complete loss of income, while others were deemed ineligible to claim their pension because of their dismissal.
As well as detailing the personal experiences of those impacted by the ban, Lord Etherton's report also makes 49 recommendations to the government including the restoration of medals that had to be handed back on dismissal or discharge, the clarification of pension rights and the presentation of the veterans badge.
The report comes more than 20 years after four servicemen and women, who were sacked for being gay, won a case in the European Court of Human Rights and overturned the ban.
Veterans Minister Johnny Mercer said he was pleased with the apology and that it was a "significant moment" for the LGBT community.
Asked why it had taken so long, with the ban lifted more than 20 years ago, he said veteran care in this country had "been a journey" and that there were lots of different parts of the "veteran experience" that needed to be brought up to standard.