SAN FRANCISCO — Tens of thousands of people waving rainbow flags lined streets for gay pride parades Sunday in coast-to-coast events that took both celebratory and political tones, the latter a reaction to what some see as new threats to gay rights in the Trump era.

In San Francisco, revelers wearing rainbow tutus and boas held signs that read “No Ban, No Wall, Welcome Sisters and Brothers” while they danced to electronic music at a rally outside City Hall.

Frank Reyes said he and his husband decided to march for the first time in many years because they felt a need to stand up for their rights. The couple joined the “resistance contingent,” which led the parade and included representatives from several activist organizations.

Activists have been galled by the Trump administration’s rollback of federal guidance advising school districts to let transgender students use the bathrooms and locker rooms of their choice. The Republican president also broke from Democratic predecessor Barack Obama’s practice of issuing a proclamation in honor of Pride Month.

At the jam-packed New York City parade, a few attendees wore “Make America Gay Again” hats, while one group walking silently in the parade wore “Black Lives Matter” shirts as they held up signs with a fist and with a rainbow background, a symbol for gay pride.

Others protested potential cuts to health care benefits, declaring that “Health care is an LGBT issue.”

“I think this year is even more politically charged, even though it was always a venue where people used it to express their political perspectives,” said Joannah Jones, 59, of New York with her wife, Carol Phillips.

She said the parade being televised for the first time gives people a wider audience. “Not only to educate people in general on the diversity of the LGBTQ community but also to see how strongly we feel about what’s going on in office.”

In Chicago, 23-year-old Sarah Hecker was attending her first pride parade, another event that attracted wall-to-wall crowds. “I felt like this would be a way to not necessarily rebel, but just my way to show solidarity for marginalized people in trying times,” said Hecker, a marketing consultant who lives in suburban Chicago.

Elected officials also made a stand, among them New York Gov. Andrew Cuomo, who said his state would continue to lead on equality.

Cuomo, a Democrat, on Sunday formally appointed Paul G. Feinman to the New York Court of Appeals.

Feinman is the first openly gay judge to hold the position. But the pride celebrations also faced some resistance from within the LGBT community itself. Some activists feel the events center on gay white men and are unconcerned with issues including economic inequality and policing.

In Minneapolis, organizers of Sunday’s Twin Cities Pride Parade initially asked the police department to limit its participation, with the chairwoman saying the sight of uniformed officers could foster “angst and tension and the feeling of unrest” after a suburban officer’s acquittal this month in the deadly shooting of Philando Castile, a black man, during a traffic stop.

The city’s openly gay police chief called the decision divisive and hurtful to LGBT officers. On Friday, organizers apologized and said the officers were welcome to march.

There were scattered counter-protests and a few disruptions, including a small group in New York urging parade-goers to “repent for their sins.”