Marion 'Suge' Knight, left, shown with his attorney Albert DeBlanc, appears in court pleading no contest to voluntary manslaughter in front of Judge Ronald S. Coen at the Criminal Justice Center in Los Angeles, Calif., on Sept. 20, 2018.

Averting a murder trial that had been nearly four years in coming, former rap mogul Marion "Suge" Knight pleaded no contest Thursday to voluntary manslaughter for running over and killing a Compton businessman and agreed to serve nearly 30 years in prison.

The Death Row Records co-founder entered the plea in Los Angeles Superior Court after striking a deal with prosecutors, and has agreed to serve 28 years. Jury selection for his trial, which could have led to a life sentence, had been scheduled to begin Monday.

Knight was charged with murder, attempted murder and hit-and-run after fleeing the scene of a dispute in January 2015 outside a Compton burger stand. Knight and Cle "Bone" Sloan, a consultant on the N.W.A. biopic "Straight Outta Compton," traded punches before Knight clipping him with his pickup truck and ran over businessman Terry Carter, who died from his injuries.

Knight's attorneys have said he was acting in self-defense and was fleeing armed attackers when he ran over Carter and Sloan. Sloan has denied he was carrying a gun during the confrontation.

During Thursday's hearing, Knight, wearing orange jail attire with his arms and legs in chains, answered Judge Ronald Coen's questions, loudly and quickly saying "no contest" when the judge asked for his plea. He will be formally sentenced on October 4.

The plea deal calls for Knight to serve 22 years in prison on the voluntary manslaughter count, and another six years because it is a third strike violation.

Knight disagreed with the judge's description of one of his previous strikes and put a pause in the proceedings that briefly raised tension in the courtroom.

"You served nine years for it," Coen said, before Knight agreed to move on.

Carter's daughter, Crystal, sat in the front row of the courtroom and displayed no visible reaction to the proceedings. "I'm surprised he pleaded out," Crystal Carter said outside court. "Normally he likes the cameras to be on him 24-7."

The agreement also absolves Knight in two other cases, both from 2014. He was accused of stealing a camera from a woman and of sending threatening text messages to "Straight Outta Compton" director F. Gary Gray.

Delays, detours and drama marked the run-up to Knight's trial, which was expected to begin Oct. 1 under tight security and secrecy. Court officials had said that no witness list would be released ahead of the trial, and that some witnesses might not be identified by name during the case.

Surveillance video that showed Knight hitting the two men with his truck was likely to play a central role for both sides.

Sloan, who had feuded with Knight for years in a dispute with roots in their Compton gang ties, was likely to have been the trial's key witness, but may have been a difficult one for the prosecution.

Despite giving a detailed account of the incident to police on the day it happened, just a few months later at a preliminary hearing he claimed to have little memory of it, and even refused at first to identify Knight as the person sitting in the courtroom who he'd fought with.

Knight collapsed during one court hearing, two of his former attorneys were indicted on witness-tampering charges, and his fiancee pleaded no contest to selling video of Knight hitting the two men with his truck.

His attorney Albert DeBlanc Jr., appointed by the court five months ago, was his 16th, and Knight tried to fire him and get yet another lawyer just a day before the deal was reached.

Knight would frequently, against the advice of Coen and his attorneys, speak extensively during hearings, complaining about jail conditions, his attorneys and his health issues.

On Thursday, while Coen read legal language about the plea and told Knight he was subject to deportation if he was not a citizen, Knight said "ICE is coming to get me?" to a smattering of laughs.

DeBlanc declined comment on the plea agreement. Prosecutors did not speak to reporters outside court.

The 53-year-old was a key player in the gangster rap scene that flourished in the 1990s, and his label once listed Dr. Dre, Tupac Shakur and Snoop Dogg among its artists. Knight lost control of the company after it was forced into bankruptcy. He has prior felony convictions for armed robbery and assault with a gun. He pleaded no contest in 1995 and was sentenced to five years' probation for assaulting two rap entertainers at a Hollywood recording studio in 1992.

He was sentenced in February 1997 to prison for violating terms of that probation by taking part in a fight at a Las Vegas hotel hours before Shakur was fatally wounded in a drive-by attack as he rode in Knight's car just east of the Las Vegas Strip. Shakur's slaying remains unsolved.