TAUNTON, Mass. – The young Massachusetts woman convicted of driving her boyfriend to commit suicide – by texting him to “get back in” his carbon monoxide-filled car – was sentenced Thursday to 2 1/2 years in prison.

There was an audible gasp in the courtroom, but Michelle Carter, 20, stared blankly ahead as Juvenile Court Judge Lawrence Moniz handed down the sentence after taking about 10 minutes to decide her fate, calling the case “a tragedy for two families.”

Carter’s lawyers immediately asked for a stay of the sentence pending an appeal. The judge agreed, a move that allows Carter to remain free for now.

If she loses her appeal, she will end up serving 15 months at Bristol House of Correction, with the remainder of her sentence suspended, according to Moniz who said he was guided by youthful-offender sentencing guidelines. Carter was 17 at the time of the suicide.

Carter could be forced to serve the remaining 15 months of her sentence if she doesn’t keep her nose clean during probation, which will run until August 2022.

Carter, who Moniz found guilty of involuntarily manslaughter in June, faced up to 20 years. Prosecutors asked for a sentence of seven to 12 years, while the defense wanted five year’s probation with mental-health counseling.

“I have not found that Miss Carter’s age or level of maturity or even her mental illness have any significant impact on her actions,” said Moniz. “She is a bright young lady, did well in school, and I am satisfied that she was mindful of the actions for which she now stands convicted. So in my deliberations that has had little weight.”

Carter — who was blasted by prosecutors as showing no remorse for her actions — said nothing in court.

Disturbing text messages at the heart of the case revealed how the then-17-year-old urged her boyfriend, Conrad Roy III, to “get back in” his truck as it filled with carbon monoxide.

“You can’t think about it. You just have to do it. You said you were gonna do it. Like I don’t get why you aren’t,” Carter texted Roy the day he killed himself in a Kmart parking lot July 12, 2014.

In other texts, Carter taunted Roy, 18 – who was depressed and attempted suicide before — about ending his life.

“But I bet you’re gonna be like ‘oh, it didn’t work because I didn’t tape the tube right or something like that,” Carter wrote. “I bet you’re gonna say an excuse like that … you seem to always have an excuse.”

Roy’s aunt called on the judge to sentence Carter, 20, to the maximum 20 years. But the woman’s father begged for a sentence of probation and counseling.

Moniz found that Carter’s texts “constituted wanton and reckless conduct.”

As part of terms of her sentence, she was ordered to have no contact with the Roy family.

She also is barred from profiting off the teen’s death by Moniz, who said she may have been motivated by “a sense of self-aggrandizement.

“This court now orders that you are not to profit from the events of which you now stand convicted,” he said about any potential books, movies or TV shows that could result from the case.

Defense argued that Carter was suffering from her own mental-health issues in 2014.

Additional reporting by Lia Eustachewich