Decades ago, an early morning raid at the Stonewall Inn in New York sparked violent protests among gay patrons who fought back after police burst in and tried to arrest them for daring to drink and dance with members of the same sex.
Nearly 50 years later, officers armed with assault rifles stand guard outside the historic bar, protecting patrons after a gunman in Florida staged a massacre at a gay nightclub and spread fear of more attacks.
The irony isn't lost on the gay community that used to see police as the oppressor and counts the 1969 Stonewall Inn raid as the start of the gay rights movement.
"Once upon a time they hit us with nightsticks, and now they're our protectors," said Gil Horowitz, 80, a retired research psychologist in New York who took part in the riots at Stonewall.
At gay pride parades this weekend, that evolution will be on display in cities like Denver, where the first parade in 1975 was in response to police raids on gay bars and arrests of gay men. On Sunday, police will march in solidarity and will have a robust presence among the crowd of 300,000 plus people.
"That's a snapshot of 40 years of progress," said Jason Marsden, executive director of the Matthew Shepard Foundation, named for the University of Wyoming gay student who died after he was beaten and tied to a fence by two men in 1998.
Living an open gay lifestyle was unheard of across most of the U.S. just decades ago, and police routinely raided private gay clubs. During the raids, vice officers would beat the patrons - sometimes the targets were those not wearing sex-appropriate clothing - and arrest them on morals charges. The persecution reflected views in society at large: Until 1973, the American Psychiatric Association classified homosexuality as a mental disorder, and it was only in 2003 that a Supreme Court ruling declared state sodomy laws to be an unconstitutional violation of personal privacy.
The change in attitude didn't happen overnight, and it doesn't mean echoes of the past don't resurface, even in places seen as progressive.
In San Francisco, the police department has been shamed by the recent discovery of racist and homophobic text messages traded by officers. And a long-standing undercover police tactic in the Southern California city of Long Beach was dealt a blow last month when a judge dismissed lewd conduct and indecent exposure charges against a man arrested in a public bathroom. The judge said police improperly targeted gay men in the sting operation.
Numerous studies in the past six years have shown there is still a strong distrust of law enforcement, especially among LGBT people feeling bias, harassment or being assaulted by law enforcement, said Jeremy Goldbach, assistant professor at the University of Southern California School of Social Work.
"The relationship has changed in some ways, but I don't know it has changed as much as we would like to think," he said.
But in cities across the U.S., police officers who once were criticized for enforcing outdated laws are instead undergoing robust LGBT cultural sensitivity training.
Atlanta's police department has two full-time officers assigned as LGBT liaisons. Officer Eric King, one of the liaisons, said they try to regularly visit and keep in touch with businesses that focus or draw LGBT customers. King, who is gay, said building a direct line of communication is important to build trust.
He hopes LGBT leaders, working with city and police officials, can develop a plan that makes people feel secure but not "like big brother is watching."
"I wouldn't want there to be an overconcentration of police where people are always in fear, but I do want them to know we're present if you need us," King said.
While large departments for years have been more welcoming to the gay community and many have gay officers on the force, rural, conservative states are trying to catch up, too.
In the Idaho communities of Boise and Pocatello and in Missoula, Montana, officers are assigned as liaisons to the gay community.
More people are openly gay and demanding they be treated as just another part of the larger community. Montana state Sen. Diana Sands said that is driving the shift in attitude.
"That change has been revolutionary in the last decade," said Sands, who is gay.
In Anchorage, Alaska, Police Chief Christopher Tolley will march in the city's parade, and has ordered extra officers to be on scene, not because there's been an identified threat but to show support for the LGBT community. And in Juneau, at a gay pride festival last weekend, a woman wearing a pride T-shirt asked a police officer if her shirt made her a target.
"I am here to put myself between anyone who would hurt you and that T-shirt," Lt. Kris Sell told her.
Looking back over nearly 50 years of progress, Horowitz, who was arrested during the second night of rioting at the Stonewall Inn, said even if things haven't come as far as they need to, the changes in society have meant there is at least the appearance of acceptance.
"Police were homophobic at that time, maybe still a little bit. They understand now they're not supposed to exhibit it," Horowitz said. "If they act as if they accept us, whether they do or not, that's all we can really ask."