NEW YORK — The City Council on Thursday passed legislation that would make it a crime to engage in revenge porn, sharing intimate images of people with an aim to embarrass or hurt them.

“We want to give prosecutors the tools they need to build these cases,” said Council Member Rory Lancman, who introduced the legislation with Council Member Daniel Garodnick.

At least 38 states plus the District of Columbia have laws to combat the problem of revenge porn, which has proliferated online.

“For too long,” Lancman said, “our laws failed to keep up with our technology, leaving victims of revenge porn unable to seek justice and hold perpetrators accountable.”

Prosecutors say it has been difficult to get justice for revenge porn victims because the images generally are initially shared between people, usually couples, with consent. They say when someone gets angry and wants to hurt his or her partner the images can be shared among friends or colleagues or uploaded to the internet on porn sites or elsewhere.

It happened to 27-year-old Nathaly Rodriquez. She said her boyfriend once secretly recorded them having sex and then when they broke up he posted the video online. She said he obscured her face but her body was there for the world to see.

“I wanted to die,” she said. “It had such a great effect on me. I was so embarrassed.”

The revenge porn bill, introduced by two Democrats, would make it a misdemeanor offense to disclose or threaten to disclose intimate images of another person without consent and with the intent to cause harm. The offense would be punishable by a year in jail and a $1,000 fine, and victims would be able to sue in civil court and recoup legal fees.

Eric Rosenbaum, an assistant district attorney in Queens, said the ordinance would make it easier to go after revenge porn crimes. Taking intimate images of someone without consent is illegal, but Rosenbaum said the problem previously was that there often was initial consent to take and share the images among partners.

“You are in a relationship with someone, and you think you can trust them, so you send the photo,” he said. “But unfortunately that’s not always the case. You can’t trust everyone. Or things change.”

The council voted unanimously to approve the ordinance. The mayor, also a Democrat, would need to sign the legislation into law.

A similar bill is stalled in the state Assembly.