Justin Trudeau has apologised for decades of state-sponsored anti-LGBTQ discrimination.

During the second half of the 20th century, the Canadian government monitored civil servants they believed to be gay or transgender, leading to thousands being fired or intimidated into leaving their jobs.

LGBTQ people were considered to be at increased risk of blackmail due to what was called ‘character weakness’.

Canadian Prime Minister Trudeau, issuing a formal apology in the House of Commons, said this historic mistreatment of the LGBTQ community is an “often overlooked part” of his country’s history.

“Imagine, if you will, being told that the very country you had willingly laid down your life to defend doesn’t want you, doesn’t accept you, sees you as defective, sees you as a threat to our national security,” Trudeau said.

“Not because you can’t do the job or because you lack patriotism or courage, no, but because of who you are as a person and because of who your sexual partners are.”

He also shone a light on some of the humiliating tests that suspected LGBTQ people were forced to undergo, including the “fruit machine”, a device which claimed to reveal a person’ sexuality based on their response to various stimuli.

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

He added: “It is my hope in talking about these injustices, in vowing to never repeat them, acting to right these wrongs, we can begin to heal.”

As well as Trudeau’s apology, the Canadian government has introduced legislation to allow people to apply to have their criminal convictions for consensual same-sex sexual activity erased from public record.

$100 million has also been set aside to compensate those whose careers were ended due to the unjust convictions.

“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,” Trudeau continued.

Watch the Canadian Prime Minister’s speech in full below.