TORONTO (AP) — Canadian Prime Minister Justin Trudeau apologized Tuesday to members of the LGBTQ community for actions taken by the government against thousands of workers in the military and public service during the Cold War.

Trudeau said in a speech to Parliament that from the 1950s to the early 1990s, the federal government employed a campaign of oppression against members and suspected members of the LGBTQ communities. The thinking of the day, he said, was that all non-heterosexual Canadians would automatically be at an increased risk of blackmail by Canada's adversaries.

"This is the devastating story of people who were branded criminals by the government — people who lost their livelihoods, and in some cases, their lives," Trudeau said.

"These aren't distant practices of governments long forgotten. This happened systematically, in Canada, with a timeline more recent than any of us would like to admit."

Trudeau said the public service, the military, and the Royal Canadian Mounted Police spied on their own people, inside and outside of the workplaces. He said Canadians were monitored for anything that could be construed as homosexual behavior, with community groups, bars, parks, and even people's homes constantly under watch. He said when the government felt that enough evidence had accumulated, some suspects were taken to secret locations in the dark of night to be interrogated.

He said those who admitted they were gay were fired, discharged, or intimidated into resignation. The prime minister called it a witch hunt.

"It is with shame and sorrow and deep regret for the things we have done that I stand here today and say: We were wrong. We apologize. I am sorry. We are sorry," Trudeau said to a standing ovation.

"For state-sponsored, systemic oppression and rejection, we are sorry."

The government also introduced legislation that would allow people to apply to have their criminal convictions for consensual sexual activity between same-sex partners erased from public record.

It has also earmarked more than $100 million Canadian (US $78 million) to compensate members of the military and other federal agencies whose careers were sidelined or ended due to their sexual orientation, part of a class-action settlement with employees who were investigated, sanctioned and sometimes fired as part of the so-called "gay purge."

"Those arrested and charged were purposefully and vindictively shamed. Their names appeared in newspapers in order to humiliate them, and their families. Lives were destroyed. And tragically, lives were lost," Trudeau said.