CHARLESTON, S.C. (AP) — A South Carolina teenager has been sentenced to 18 years in prison in the stabbing death of another teen more than two years ago.

Local media outlets report 19-year-old Matthew Fischer was sentenced Wednesday in court in Charleston.

Fischer had pleaded guilty voluntary manslaughter. Prosecutors say he stabbed 17-year-old Lucas Cavanaugh to death in Mount Pleasant in 2015 in a dispute over a girlfriend. Fischer had said he was defending himself.

Fischer had been charged with murder, which carries a penalty between 30 years and life in prison.

Prosecutors have pointed to text messages before the fatal confrontation in which Fischer told Cavanaugh that he would kill him.