Sometimes the police could identify a gay man by his red tie. In other cases, it could be his tennis shoes. Or maybe they just knew one when they saw one.

As preposterous as it may seem, the police once relied on such seemingly innocuous clothing choices or even a man’s perceived feminine look to target “suspected homosexuals,” as detailed in the new book “Vice Patrol: Cops, Courts, and the Struggle over Urban Gay Life Before Stonewall” by Anna Lvovsky ’13, assistant professor at Harvard Law School. The book, which focuses on the roles of the police and judges in policing gay life in the mid-20th century, originated as her thesis topic (she received her Ph.D. in the History of American Civilization from Harvard in 2015). During her research, she was struck by policing manuals she discovered from an era that focused on visualizing the “deviant body” as a way to stop sex-related offenses, particularly those of gay men.

“There has long been a certain instinct to contain and redress … the possibility of deviance by essentially mapping deviance onto something that’s conspicuous and visible and therefore easily distanced from the self,” she said in an interview. “There’s something deeply reassuring about being able to both distance oneself from the deviant body and to assert that one can understand and grasp and therefore contain — conceptually at least — the figure of the ‘deviant.’”

The book begins after Prohibition ends, when laws were enacted to regulate how drinking establishments could operate their businesses and how their customers behaved. Enforcement often turned on whether or not bar owners knew that the patrons they served were gay, as shown in administrative proceedings detailed by Lvovsky featuring police testimony on “rouged faces,” or the “effeminate” way a customer spoke. She includes details about the cat-and-mouse game bar owners played with the police: One owner implemented secret signals to alert customers upon police entry to act “in a normal well-behaved manner,” while another signaled an accepting atmosphere with a sign advertising “Pickled eggs laid by gay roosters.”

When cited for violations, bar owners contended that they couldn’t reliably “recognize a homosexual” or questioned the police’s qualifications to do so. In time, the owners enlisted expert testimony that framed homosexuality as a disease best addressed by medical authorities — ironically using rhetoric often remembered for its harm to LGBT communities.

By the early 1950s, police started using plainclothes officers and decoys in specialized vice squads to initiate arrests. These efforts ranged from officers flirting with men in bars to decoys exposing themselves in public bathrooms in order to entice solicitations. When these cases went to court, judges frequently objected to these tactics, calling them a waste of police resources or questioning the morality of such manipulation. According to Lvovsky, judges’ more permissive attitudes partly reflected a growing liberalization among the educated and elite of the period, but primarily stemmed from institutional pressures within the courts, from judges’ concern about their workloads to their professional relationships with psychiatrists. Yet she also emphasizes that the frequent leniency judges showed toward the accused should not minimize the harms suffered by those targeted by the police.

“There’s no question that policing was a major shadow in the lives of essentially anyone living a socially active life in gay or lesbian circles, particularly in gay circles.”

“There’s no question that policing was a major shadow in the lives of essentially anyone living a socially active life in gay or lesbian circles, particularly in gay circles, in these years,” Lvovsky said. “Even though many judges would reduce charges or would sometimes dismiss or acquit, the majority of defendants were still convicted of some kind of misdemeanor offense. And being brought into the criminal justice system is itself a great cost. Even when defendants don’t suffer direct penal consequences, there’s a certain psychological insecurity and fear of exposure to friends, family, and employers that come from any close encounter with the justice system. So that’s absolutely a very important part of the story.”

Her book concludes in the 1960s, when the popular media began to cover gay culture and attempts by the the vice squads to regulate it. While press coverage was not necessarily sympathetic to the gay community, Lvovsky writes that it brought unfavorable visibility to the manipulative practices of vice officers, whose “expertise in an ostensibly deviant sexual culture did not bolster their standing in public debates about sexual difference. It undermined the legitimacy of their operations, casting the specter of deviance on the experts themselves.”

Changes came later in the decade, as activists and critics pressured police departments to limit their undercover tactics, judges imposed legal limits on police surveillance, and courts prohibited liquor boards from suspending licenses because of the mere “presence of apparent homosexuals.” Those changes mirrored growing attention to police abuses and support for sexual privacy, writes Lvovsky, but they also “reflected a shifting view of homosexuality itself.” Policing that targets LGBT people, which spurred the Stonewall riots of 1969, persisted into later decades and still occurs today on a smaller scale, she writes. Yet the practice of vice officers immersing themselves in gay life and culture was primarily a feature of the mid-20th century, according to Lvovsky. That history remains relevant, she writes, in helping us understand how police enforce laws against marginalized populations, in areas such as narcotics, prostitution, terrorism, and gang activity: “The painful, contested tale of the state’s attempts to regulate gay life in the United States may be a classic case of history not simply showing us a shameful past, but also casting light into the hidden corners of the present.”