Massachusetts on Thursday became the 49th state to prohibit revenge pornography, with Gov. Maura Healey signing a bill that also cracks down on sexual harassment and coercive control by domestic abusers.

The bill closes a legal loophole to prohibit sharing sexually explicit images and videos without a subject’s consent; creates a new diversion and education program for adolescents who engage in sexting; explicitly bans artificially generated material purporting to depict a real person in a sexually explicit manner, often called “deepfakes,” and expands the definition of criminal abuse to include “coercive control.”

Survivors and victims’ rights advocates say revenge porn has grown common in the digital age, subjecting people -- particularly women -- to social and emotional harm often inflicted by former romantic partners.

Lawmakers tried to crack down on revenge porn last year, but senators didn’t leave themselves enough time in the end-of-session push to close a loophole in state law that makes prosecution of revenge porn cases nearly impossible. Part of the problem, reform advocates say, is a 2005 Supreme Judicial Court ruling that made it difficult for prosecutors to pursue charges unless three or more incidents took place.

“As a former attorney general, and a prosecutor, and now as governor, we know that there have been gaps involved in policy in this area,” Gov. Maura Healey said at a press conference Thursday before signing the legislation into law.

Katelynn Spencer, an advocate and survivor, told her story Thursday of discovering that sexual videos of her had been posted without her consent to pornography websites. The videos, one of which she didn’t know had been taken, had been on the internet since 2012, she said, though she didn’t find out about it until 2020.

“It’s been all over many different websites with millions of views. Right away I knew I wanted justice. But then I discovered there was no law in Massachusetts to protect me,” Spencer said. “Though I did try to charge my exploiter, my case was dismissed.”

The bill was signed into law years after it was first introduced to lawmakers.

“The bill has been in the making for so long; since before I found out I was exploited,” Spencer said. “I can finally now say I have justice because this bill is going to help so many people.”

Spencer and Shaquera Robinson, a domestic abuse survivor who founded the Together Rising Against Coercion Coalition and Shaquera’s Story Domestic Violence Consulting and Coaching, held each other and cried after Healey scrawled her name across the legislation.

New provisions were added to the bill this session to criminalize coercive control as a form of abuse, and update revenge pornography laws to include artificial intelligence.

“We also know that this is a new area in the sense of AI and what is enabled out there,” Healey said. “Particularly, stories continue to be told about young people and what’s happening in this space.”

“Deepfakes” -- AI-created images or videos that often depict situations, actions or speech that never really happened -- are increasingly used to create nonconsensual pornographic images, bill authors have said. Advocates have warned that this trend is increasingly popping up among young people, who are creating and sharing synthetic images of other teenagers.

“We’re dealing with artificial intelligence that’s moving leapfrogs ahead of what we are legislating,” said Rep. Michael Day, one of the authors of the bill. “And that happens with all technology. What we did in this bill is put in specific prohibitions against deepfake actions, which are designed to ... harm somebody by manipulating their image and putting it out there, even attempting to ruin their lives.”

The law also features language expanding the definition of abuse to include coercive control, which includes behaviors aimed at limiting a victim’s safety or autonomy.

Coercive control is “a pattern of behavior intended to threaten, intimidate, harass, isolate, control, coerce or compel compliance of a family or household member that causes that family or household member to reasonably fear physical harm or have a reduced sense of physical safety or autonomy,” according to the definition in the new law.

This can include purposefully isolating a person from sources of support like family and friends, depriving them of basic needs, controlling or monitoring their communications, movements and finances, threatening to harm a child or other family member, or abuse an animal to force a person to do something, or threatening to publish sensitive personal information, including explicit images or videos.

“This is violence that may not be physical in nature, but it nonetheless still causing lasting harm and trauma,” Lt. Gov. Kim Driscoll said Thursday. “And very often, it’s the precursor to physical harm. Making it clear that this behavior is criminal will prevent harm, prevent violence and support survivors of domestic violence.”

Robinson, recounting her and her children’s experiences surviving domestic abuse, said if this law had been in place “during the height” of her trauma, she may not have had to endure “the loss of employment, the fears of not knowing what was the next step.”

“Passing this bill means that survivors’ voices can be not just heard, but that we are believed and that we now have a criminal legal system that finally gets it,” Robinson said.

Christina Pavlina -- co-founder and executive director of Jane Does Well, a nonprofit that provides divorce support for women and children -- told the News Service that Massachusetts follows New Jersey, Connecticut and California in adding coercive control to the legal definition of abuse.

“For the first time, when a victim faces the court, a judge will understand that if a victim has been isolated, or threatened and intimidated, even if there’s no physical scars, that there’s been a power imbalance,” Pavlina said.

The bill also creates new education and diversion programs to deal with teen “sexting.”

It requires the Department of Elementary and Secondary Education to encourage school districts to implement age-appropriate instruction and media literacy skills for all grade levels about sending and receiving sexually explicit text messages.

“As a mayor and former chair of the school committee, it’s critically important that we have the tools that we need at grade level,” Driscoll said. “It’s so critical to make sure young people understand the dangers of this activity, especially as the technology available to them is rapidly changing.”

With Healey’s signature on Thursday, Massachusetts became the 49th state to explicitly ban revenge porn, with South Carolina now as the only outlier.

Asked by reporters why it took so long, Senate President Karen Spilka said it is “a complicated issue.”

“[It’s a] very emotional issue for people. Legislators were working hard, and now it is actually a more comprehensive bill with the AI piece than it would have been a few years ago, and other pieces. But I know Sen. Keenan, Sen. Eldridge, Rep. Day worked really hard on getting it done, and brought it to the finish line, so I commend them for their hard work,” Spilka said.

Former Gov. Charlie Baker and Lt. Gov. Karyn Polito pressed lawmakers for several years to pass legislation to punish the nonconsensual spread of someone else’s nude photos or videos. Healey, Driscoll nor any of the lawmakers mentioned Baker or Polito at the press conference.

Asked by a reporter how much credit is due to the former Republican governor, Spilka said she thanked Baker for his work, but “the biggest thanks goes to the survivors.”

“Survivors and those that have gone through, by telling, by having the courage to tell their stories, when there was so much trauma and pain involved -- that really made a difference,” Spilka said. “The survivors are the ones that made a difference and carried this across the finish line.”