Brandon McInerney, the 17-year-old student who pleaded guilty to the second-degree murder of gay teen Lawrence King, was sentenced to 21 years in prison on Monday, CBS News reported.

McInerney's lawyer said his client was deeply remorseful for his actions.

“He feels deeply remorseful and stated repeatedly if he could go back and take back what he did he would do it in a heartbeat,” Scott Wippert said.

Two months after a judge in California declared a mistrial when jurors could not decided whether McInerney, then 14, deserved to be convicted of voluntary manslaughter or first-degree murder, McInerney pleaded guilty to second-degree murder, voluntary manslaughter and use of a firearm as part of a plea deal.

King, 15, was shot twice in the back of the head during an E.O. Green Junior High School computer class on the morning of February 12, 2008. He died in the hospital on Valentine's Day.

King told friends and family he was gay and often wore makeup to school. Students testified that he either had a crush on McInerney or delighted in teasing the boy, asking him, “What's up baby?” the day before King's murder.

During the trial, defense lawyers argued that McInerney suffered abuse at the hands of his drug-abuser father, and didn't deserve to be tried as an adult.

Family members testified that the McInerneys divorced in 2000 amid allegations of spousal abuse and drug addiction, and that the father, who has subsequently committed suicide, often humiliated his son in public.