LOS ANGELES — Nine Democratic presidential candidates vowed Thursday to reverse President Trump’s rollbacks of LGBTQ rights as they sought to appeal to a key group of voters in the race for the party’s 2020 nomination.

In back-to-back appearances at a CNN town hall in Los Angeles, the Democrats sketched out similar agendas on LGBTQ issues. One after another, they vowed to reverse Trump’s ban on transgender people serving in the military and to outlaw discrimination on the basis of sexual orientation or gender identity.

The most warmly received candidate was Pete Buttigieg, the mayor of South Bend, Ind., who spoke at the last primary debate about his decision to publicly come out as gay soon after returning from war.

In criticizing the ban on transgender troops, the 37-year-old military veteran who served in Afghanistan took a swipe at the president for getting a medical deferral to avoid service in the Vietnam War.

“The transgender military ban is an outrage against the willingness of service members to put their lives on the line for this country, and they are having their careers threatened by a president who avoided serving when it was his turn,” he said to a burst of applause. “That is dead wrong.”

Turning to the mental health of LGBTQ youth, Buttigieg called for a national “three-digit suicide prevention hotline.” He also bemoaned the federal rule barring blood donations by men who have had sex with another man within the past year.

“My blood’s not welcome in this country,” he said, “and it’s not based on science; it’s based on prejudice.”

The forum, sponsored by the Human Rights Campaign Foundation, came as public support for LGBTQ rights has been rising. Large majorities of Americans back same-sex marriage and oppose the ban on transgender people in the military.

Trump promised during his 2016 campaign to be a friend to LGBTQ Americans, but as president has sought on multiple fronts to roll back their rights.

His administration argued before the U.S. Supreme Court on Tuesday that the Civil Rights Act of 1964 does not bar employers from firing workers based on their sexual orientation or gender identity.

In the hours before the town hall, three of the candidates — Massachusetts Sen. Elizabeth Warren, California Sen. Kamala Harris and Buttigieg — released plans to strengthen LGBTQ rights in largely similar ways. Former Rep. Beto O’Rourke of Texas had put out his LGBTQ agenda in June.

Michael Finnegan is a Los Angeles Times writer.