Massachusetts’ highest court ruled Wednesday that a man who took cellphone photos up the skirts of women riding the subway did not violate state law. Lawmakers are vowing to act quickly to change that.

BOSTON — Massachusetts lawmakers are vowing to act quickly to pass legislation outlawing the taking of photographs up the skirts of women in public.

The sense of urgency on Beacon Hill Thursday comes a day after the state’s highest court ruled that a man who took cellphone photos up the skirts of female passengers riding the Boston subway did not violate state law.

The Supreme Judicial Court said Peeping Tom laws protect people from being photographed in dressing rooms and bathrooms when nude or partially nude, but the way the law is written, it doesn’t protect clothed people in public areas.

House Speaker Robert DeLeo said lawmakers are racing to get a bill to Gov. Deval Patrick’s desk as soon as the end of the day. DeLeo said he thought the state’s existing laws were sufficient to prosecute those who took “upskirt” photos.

DeLeo said lawmakers are trying to be careful to make sure that any bill rushed through will withstand constitutional challenges. He also defended the decision to push through a bill without holding a public hearing.

“We want to make sure that we get the language right,” DeLeo told reporters. “It’s something which appalls us greatly. We’re outraged by what has occurred and we want to make sure that these types of action are dealt with in our court system and dealt with swiftly.”

Wednesday’s court decision overruled a lower court that had upheld charges against Michael Robertson, who was arrested in August 2010 by transit police who set up a sting after getting reports that he was using his cellphone to take photos and video up female riders’ skirts and dresses.

“A female passenger on a MBTA trolley who is wearing a skirt, dress, or the like covering these parts of her body is not a person who is ‘partially nude,’ no matter what is or is not underneath the skirt by way of underwear or other clothing,” the court said in its ruling.

State law “does not apply to photographing (or videotaping or electronically surveilling) persons who are fully clothed and, in particular, does not reach the type of upskirting that the defendant is charged with attempting to accomplish on the MBTA,” the court said.

The SJC said that while such actions should be illegal, they are not, given the way state law is written.

In the past three years, MBTA police have investigated 13 “secretly photographing” cases. In some cases, the alleged offender was issued a court summons. Some remain open investigations. During those three years, the MBTA reported an average of 395 million passenger trips.