TORONTO—The well-known Toronto pastor who officiated Canada’s first legally recognized same-sex marriages delivered his final sermon Sunday.

Rev. Brent Hawkes, who is also known for officiating Jack Layton’s state funeral in 2011, is retiring after serving as senior pastor at the Metropolitan Community Church of Toronto for more than 40 years.

In 2001, the openly gay pastor married two same-sex couples using a legal loophole: the ancient Christian tradition of publishing the banns of marriage.

At the time, same-sex couples could not obtain marriage licences from municipal clerks, but the Ontario Marriage Act allowed couples to be granted a licence if their names were published and read out at church for three Sundays in a row.

But when the couples tried to have the marriages registered with the province, they were refused.

The couples and the church sued, and the Ontario Court of Appeal eventually recognized their unions in a 2003 ruling that paved the way for same-sex marriage to be legalized across the country.

Hawkes was appointed to the Order of Canada in 2007 for his work advocating for gay rights.

He will be succeeded as senior pastor by Rev. Jeff Rock.