OTTAWA (Reuters) - Canadian Prime Minister Justin Trudeau apologized on Tuesday for a decades-long campaign by previous governments to rid the military and public service of homosexuals, calling the dark chapter in the country’s history a “collective shame.”

Canada's Prime Minister Justin Trudeau wipes away tears while delivering an apology to members of the LGBT community who were discriminated against by federal legislation and policies, in the House of Commons on Parliament Hill in Ottawa, Ontario, Canada, November 28, 2017. REUTERS/Chris Wattie

From the 1950s to the early 1990s, the Canadian government monitored and interrogated civil servants who were believed to be homosexual or transgender. Thousands in the public service, military and Royal Canadian Mounted Police were fired or intimidated into leaving their jobs.

Speaking in the House of Commons, Trudeau said the thinking that homosexuals would be at increased risk of blackmail by Canada’s adversaries resulted in nothing short of a witch hunt.

“The government of Canada exercised its authority in a cruel and unjust manner,” Trudeau said, to a standing ovation from all parties.

“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,’” he said.

The apology was the latest in a series of statements by the two-year-old Liberal government seeking to make amends for historical wrongs. Trudeau used a speech to the U.N. General Assembly in September to acknowledge Canada has failed its indigenous people.

Trudeau hugged several gay legislators in the House of Commons after giving his speech.

Gay rights group Egale described the apology as hugely significant.

“We have knocked on this door for a very long time asking to come in. Today we came in and we came in strong ... we are OK. It’s OK to be queer in Canada,” the group’s executive director Helen Kennedy told reporters.

Canada has also reached an agreement in principle with those involved in a class action lawsuit related to the government’s persecution of homosexuals, Trudeau said.

Under the agreement, C$110 million ($85.80 million) will be given in compensation to those involved in the lawsuit.

Liberal cabinet minister Scott Brison, who is gay, told reporters he was “deeply saddened by and sorry for the systemic oppression against members of my community.”

Brison added: “I am so proud today of the diversity and inclusion of our public service.”

The government earlier on Tuesday also proposed legislation that will allow the criminal records of those convicted of sexual activity with same-sex partners to be permanently destroyed.