A member of Alberta's United Conservative Party is apologizing for making what he says was an unintentional comparison between the rainbow LGBTQ pride flag and swastikas in a speech this weekend.

John Carpay issued a statement Sunday evening, saying he wished to clarify the remarks he made at a conference organized by the conservative news outlet Rebel Media in Calgary the previous day.

In the statement, Carpay says he was discussing the nature of totalitarianism when he "referred in the same sentence" to the rainbow flag and the flags bearing Nazi and communist symbols.

In doing so, he says he "unintentionally drew a broad comparison" between them.

He says he meant to stress the need to defend fundamental rights such as free speech, and that slogans touting diversity and inclusion have been abused in ways that undermine those freedoms.

Carpay, a lawyer and president of the Justice Centre for Constitutional Freedoms, is behind a legal challenge to Alberta's law on gay-straight alliances.

The law bans schools from telling parents if their children join the peer groups meant to make LGBTQ kids feel welcome and to prevent bullying.

A video of Carpay's remarks, posted on YouTube by Rebel Media, shows him discussing the court case and suggesting the law on gay-straight alliances is "a type of law that they would have in Nazi Germany of Communist Russia."

He later says: "How do we defeat today's totalitarianism? Again, you've got to think about the common characteristics. It doesn't matter whether it's a hammer and sickle for communism, or whether it's the swastika for Nazi Germany or whether it's a rainbow flag, the underlying thing is a hostility towards individual freedoms."

Rebel Media has come under fire for its coverage in the past, with several conservative politicians -- including UCP Leader Jason Kenney -- denouncing its editorial direction in the wake of last year's protests in Charlottesville, Va.

At the time, Kenney said on social media that he had "publicly condemned their alt-right editorial direction of recent months."