A US teenager who shot dead a gay classmate he believed was flirting with him has pleaded guilty to second-degree murder.Brandon McInerney smuggled a handgun into his school near Los Angeles in February 2008 and shot Larry King, 15, twice as he sat at a computer.Under a plea deal, the 17-year-old admitted the murder charge, voluntary manslaughter and use of a firearm.He could face a jail term of 21 years when he is sentenced on 19 December.McInerney would be nearly 39 years old when released.The plea deal avoids the need for a retrial after the first one ended in September with jurors unable to reach a unanimous decision.McInerney was 14 when he shot Larry King from behind in front of other students in a computer class in the city of Oxnard, southern California.His lawyer had not denied that his client pulled the trigger, but said the teenager had reached an emotional breaking point over unwanted sexual advances by the victim.During the first trial, prosecutors said McInerney had been inspired by white supremacist beliefs.The victim\'s father, Greg King, said on Monday afternoon: \"Larry had a complicated life, but he did not deserve to be murdered,\" reports the Los Angeles Times.