Former rap mogul Marion “Suge” Knight has pleaded no contest to voluntary manslaughter for running over and killing a Compton businessman nearly four years ago.

The Death Row Records co-founder entered the plea in Los Angeles superior court and has agreed to serve 28 years in prison. The plea came days before jury selection was scheduled to begin in the long-delayed case.

Knight was charged with murder, attempted murder and hit-and-run after fleeing the scene of an altercation in January 2015 outside a Compton burger stand. Knight and Cle “Bone” Sloan, a consultant on the NWA biopic Straight Outta Compton, were involved in a fistfight that ended with Knight clipping the man with his pickup truck and running over businessman Terry Carter, who died from his injuries.

Knight’s attorneys have said he was acting in self-defence 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 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 4 October.

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.

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.”

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

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. DeBlanc declined to comment on Thursday.

While awaiting trial, Knight was also accused of threatening F Gary Gray, the director of Straight Outta Compton.

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.

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 previous 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 the 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.

Knight had faced life in prison if convicted of murder for killing Carter.