The San Francisco Gay Men’s Chorus sang “Give ’Em Hope” for a revered and in some ways surprising guest who shared a California stage with them last month: Justice Anthony M. Kennedy.

Justice Kennedy was in San Francisco for an American Bar Association meeting, but he was also there to be celebrated by the men on the risers behind him. In remarks from the stage, San Francisco’s mayor, Edwin M. Lee, thanked the justice “for upholding the Constitution and justice for all” in his majority opinion in June in United States v. Windsor, a major gay rights victory.

“Freedom is always a work in progress,” Justice Kennedy said in his own remarks, making clear that there was more work to be done.

Justice Kennedy has emerged as the most important judicial champion of gay rights in the nation’s history, having written three landmark opinions on the subject, including this summer’s Windsor decision, which overturned a ban on federal benefits for married same-sex couples. Those rulings collectively represent a new chapter in the nation’s civil rights law, and they have cemented his legacy as a hero to the gay rights movement.