Story highlights "I understand why" the plea deal was reached, the victim's father says

Brandon McInerney, now 17, agrees to plead guilty for killing a junior high classmate

The sentence includes 11 years for manslaughter, 10 for using firearm

The jury couldn't decide earlier this year whether to convict him of murder or manslaughter

Months after a jury couldn't decide his fate, a Southern California teen has agreed to plead guilty for gunning down a gay classmate three years ago in their junior high classroom.

In September, a judge declared a mistrial in the case of Brandon McInerney, now 17, after jurors said they were hopelessly deadlocked following a nine-week trial on whether he should be found guilty of manslaughter or murder. The next month, the Ventura County District Attorney's Office announced that McInerney would be retried on first-degree murder charges as an adult. McInerney also was tried as an adult in the first trial.

The district attorney's office said Monday that, since then, it had "carefully reviewed the jury's determination" and talked with some jurors. It also engaged in talks with the victim's family, McInerney and his attorneys after which the relevant parties "agreed upon a disposition that balances the unique facts of the case with the need to protect the public."

Specifically, McInerney pleaded guilty to killing Lawrence King "under the penal code sections for both murder and voluntary manslaughter," as well as to using a firearm in that crime. He will serve 11 years for manslaughter and 10 years for the use of a firearm, according to the district attorney's office. His formal sentencing is set for December 19.

"He will serve the entire 21 years without time off for good behavior and will not receive time off his sentence for the three years and nine months he has spent in juvenile hall before sentencing," the prosecutor's office said, concluding that he'd then serve nearly 25 years total.

Had he been convicted on all the new charges , McInerney would have faced a maximum sentence of 50 years to life in prison.

His defense attorney, Scott Wippert, told CNN affiliate KABC he thought the sentence was "appropriate ... given all of the circumstances and all the evidence that came out at trial."

"Obviously, we've always been of the opinion that he should have been tried as a juvenile," Wippert said. "But that aside, given that he's in adult court, I think that this sentence reflects the sentiments of the jury."

McInerney was 14 when he brought a handgun belonging to relatives to E.O. Green Junior High School in Oxnard, prosecutors said.

He shot the 15-year-old King twice at point-blank range in the back of the head, while both were typing papers in a computer lab for their English class along with two dozen students and their teacher, authorities said.

Friends said King, an eighth grader who lived in a group home called Casa Pacifica, was proud of being openly gay. He liked wearing jewelry and makeup to school and he often wore high-heeled boots with the school uniform. He asked his teachers to call him Leticia instead of Larry. Some students bullied him, pupils said.

Other students said McInerney was also subject to some harassment because King had a crush on him and made it publicly known.

The Ventura County district attorney's office on Monday acknowledged criticism about its decision to try McInerney as an adult. The office stood by its decision, saying the options "available in the juvenile system were inadequate."

"This (plea agreement) is based upon the unique facts and circumstances of this case, and we believe it is a just result that balances the age and maturity level of the defendant with public safety and the gravity of the crime," the office said.

The victim's father, Greg King, described the plea agreement as "bittersweet," saying he didn't think the sentence equated to the crime but understood the thinking behind the deal.

"I think they should have taken another shot at it, but I understand why they didn't," he told CNN affiliate KCAL. "But we've been going this for ... years and at least there's some closure coming up."