PROVIDENCE, R.I. — A drug dealer who sold fentanyl to a woman who overdosed and immediately died was convicted Wednesday of second-degree murder and sentenced to 20 years in prison.

It’s the first time in Rhode Island, since the opioid crisis began, that a drug dealer was convicted of murder for selling drugs that killed someone, according to the attorney general’s office, which said it is also believed to be among just a handful of such cases nationally.

Aaron Andrade, 25, pleaded no contest to the charge Wednesday and was sentenced to 20 years in prison, with an additional 20 years suspended with probation.

Prosecutors said Kristen Coutu, 29, thought she was buying heroin in February 2014, but that Andrade sold her the powerful drug fentanyl, instead.

Coutu had struggled with a heroin addiction for several years, and had come home from a month’s stay in a rehab facility in Texas the previous night, according to her mother, Sue.

She bought $40 worth of what she thought was heroin, and injected it on the spot, prosecutor Jim Baum said. Coutu died immediately and was found in her car a few hours later.

Superior Court Judge Kristen Rodgers choked up during the hearing.

“Her death should not be in vain,” Rodgers told the courtroom, adding that the sentence sends a message to drug dealers. “Their actions, putting dangerous drugs on the street, will result in a murder charge.”

Coutu’s mother said outside court that she didn’t know if the sentence would make a difference in the opioid crisis, but she hoped it would.

“There is so much heroin and fentanyl that’s flowing through the state and every state right now. It’s hard to say if it will make a difference with just one person,” she said.

“I would think if you are a small-time drug dealer, you would think twice before selling again.”