Police crowded the Stonewall Inn, beating the bar’s patrons with nightsticks and brandishing their guns. In 1969, it was common practice for police officers in New York and other cities to harass owners and patrons of bars that they suspected of providing safe harbor for gay people.

At the time, the NYPD was engaged in a broad effort to crack down on gay bars for supposed liquor license violations.The Stonewall Inn’s patrons—drag queens, homeless youth, openly gay men—were accustomed to being hassled by the police because of their sexual orientation.

Tonight, though, they fought back. The Stonewall Riots became a landmark in LGBTQ history, setting the stage for decades of struggle for civil rights. And now, nearly 50 years after the historic uprising, the New York Police Department has apologized for its role both in the events at Stonewall and the actions it took to uphold laws that discriminated against gay people.

NYPD police commissioner James P. O’Neill made the apology at a June 6 safety briefing. “The actions taken by the N.Y.P.D. were wrong — plain and simple,” he said, according to Reuters.

O’Neill’s statements—made after years of NYPD refusal to address police violence toward LGBTQ people during the 1960s—mark the first time the NYPD has apologized for its actions during an era of widespread discrimination against people who engaged in same-sex relationships. At the time of the Stonewall riots, homosexuality was considered perverted, pathological and even un-American.

During the 1950s, the State Department purged its ranks of gay and lesbian people, and anti-sodomy laws made sex between men illegal in most states. The American Psychology Association listed homosexuality as a mental disorder, and public displays of homosexuality were punished.

Bettmann Archive/Getty Images
In 1962, the NYPD broke up the National Variety Artists' Exotic Carnival and Ball on charges of masquerading and indecent exposure, the primary target being the trans community and men in drag.

New York police officers had a long history of targeting LGBTQ people, and regularly raided gay bars using liquor licensing as a pretext. Like many other gay bars in New York, the Stonewall Inn was Mafia-owned. For many patrons, this provided a sense of protection, as the Mafia was widely known to bribe the NYPD in exchange for the right to operate without harassment.

READ MORE: How the Mob Helped Establish NYC’s Gay Bar Scene

But on June 28, 1969, law enforcement did raid the bar as part of a wider attempt to shut down gay bars. The Stonewall Inn’s proprietors were usually aware of upcoming raids thanks to their bribes, but this raid was a surprise. A crowd gathered as police seized liquor and attempted to arrest Stonewall patrons, many of whom resisted arrest.

When violence broke out among the crowd, police brandished their weapons and escalated the chaos. “The cops were, you know, they just panicked,” recalled Sylvia Rivera, a drag queen who was on the front lines of the uprising. “Inspector [Seymour] Pine…did not expect any of the retaliation that the gay community gave him at that point.”

In the wake of that retaliation, police ended up barricading themselves inside the bar until backup arrived. A full-scale riot ensued.

Out of that riot emerged the first glimpse of gay liberation in the United States. The uprising not only catalyzed the movement for LGBTQ equality, but gave unprecedented visibility to gay people fighting for their rights. Today, the site of the Stonewall Inn is the United States’ first national monument to gay rights.