The Canadian government will pay up to 110 million Canadian dollars, or $85 million, to compensate victims of the so-called “gay purge,” decades of government-authorized discrimination against gay Canadians.

The announcement on Tuesday followed a speech in the House of Commons in Ottawa by Prime Minister Justin Trudeau, who apologized to the victims. The government program, which lasted for more than 30 years and ended only in the 1990s, caused thousands to lose their jobs and sometimes face prosecution because of their sexual orientation. The policy affected Canadians in the military, the public service and the Royal Canadian Mounted Police.

The government also introduced legislation to expunge “unjust convictions” from the judicial records of people charged under laws that criminalized homosexuality.

In a speech to victims and their supporters who had gathered in the gallery of the House of Commons, Mr. Trudeau apologized for “Canada’s role in the systemic oppression, criminalization, and violence” against sexual minorities.