A court in the US is due to sentence Brandon McInerney, the Californian student who last month pleaded guilty to the second-degree murder of gay classmate Larry King.

McInerney is expected to receive 21 years in prison as part of a plea bargain he made with the Ventura County court.

McInerney was 14 when he shot King in the back of the head during a lesson in 2008.

Initially, he claimed that King, who identified as gay, had teased and provoked him and claimed he had acted without thinking when he shot his classmate.

The court heard, however, that he had informed a fellow student of his intention to kill King the night before the shooting.

A mistrial was declared in September when jurors were unable to decide whether McInerney had committed first- or second-degree murder, or manslaughter.

Shortly after the mistrial, McInerney admitted second-degree murder, voluntary manslaughter and use of a firearm as part of a plea deal.

The district attorney’s office said the plea deal meant McInerney would serve 11 years for voluntary manslaughter and 10 years for the use of a firearm, but would not serve time for the murder.

At the time, McInerney’s attorney Robyn Bramson told Reuters: “It’s very unorthodox. Both sides wanted to resolve it for various reasons, and this was just our way of getting to something that was tolerable for both sides.”

McInerney, who has already served four years in custody, is due to be given the maximum sentence for the manslaughter and firearm charges.

Last month, Rush Limbaugh blamed the Ventura County school’s “agenda” for the killing.

By allowing King to dress in feminine clothes, the school had said it was acting in accordance with rights to self-expression and it could not force King to dress differently.

Limbaugh said: “Can you imagine if the kid were a conservative and wanted his civil right to indulge and inform himself about conservatism, whether the school would have said, ‘Hey, there’s nothing we can do’”.

He said King had died as a result of the “agenda” of Green Middle School, in Oxnard, California.