In 2015, Ms. Sinclair reached out to Ms. Lilley, a friend, to start a Free the Nipple movement in New Hampshire. Ms. Pierro’s arrest got their attention, so on a Tuesday, the two friends, both topless, sat on their blanket and beach chairs. About 20 minutes later, the police arrived and asked them to cover up.

Ms. Sinclair said that they refused, and that she pointed out that New Hampshire makes no mention of breasts or nipples in the state’s indecent exposure law. They were handcuffed and brought to a police car, she said. Inside, an officer covered her up with a towel.

“When we were driving in the car, there was a guy — totally shirtless — walking outside,” she said. “And I was like, ‘Oh, are you going to get him?’”

In the Supreme Court ruling, Associate Justice Anna Barbara Hantz Marconi, who wrote the majority opinion, accepted previous courts’ logic that female and male bodies come with different definitions for what constitutes nudity. In a 1975 case that she cited, a California appeals court judge wrote that “nature, not the legislative body” made that distinction.

The New Hampshire attorney general’s office, in defending the city’s 1998 ordinance, argued that the law is applied fairly to men and women because the body parts expected to be covered up are based on social norms. The city is simply trying to prevent public disturbances, the office argued.

Jane E. Young, a deputy attorney general, declined to comment apart from the state’s brief.

The court ruling also held that the city’s ordinance did not violate the women’s freedom of speech.

Dan Hynes, the lawyer who represented the three women, said that they had each been fined $124 for violating the ordinance, but that their fines were suspended for good behavior. In an interview Saturday, he said that although his clients were disappointed by the decision, they were encouraged by the dissenting opinion, which concluded that the city’s ordinance was discriminatory.