A man who pleaded guilty in the 2018 murder of rapper XXXTentacion in exchange for testifying against the other three suspects learned his fate Wednesday.

Broward Judge Michael Usan showed leniency to Robert Allen, sentencing him to seven years in prison followed by 20 years of probation for his role in the killing.

“I genuinely believe that you are sorry for what you’ve done and not merely sorry for yourself and I think the remorse that you’ve shown is genuine,” Usan told Allen at the court hearing.

Allen, who had been facing a maximum sentence of life in prison, expressed his regret to the judge and apologized to the family of XXXTentacion.

“To say I’m sorry does not even begin the true inner remorse I want to make known,” he said. “I know that these words that I will speak will never erase the pain and sorrow and loss of what the family will have from now on. There isn’t a day that goes by that I don’t think about what happened and beg for forgiveness from God.”

Allen, who’s spent nearly five years behind bars since his arrest, will get credit for time served. He had pleaded guilty last year to second-degree murder and robbery with a firearm in the case.

His attorney, Jim Lewis, said Allen had a lesser role in the rapper’s killing than the other three suspects.

“The crime was horrible but he did what he could to try and make it right and I think the court saw that and saw real remorse and is giving him at least an opportunity to show that he’s learned from this and never do anything like this again,” Lewis said.

The other three suspects, Dedrick Williams, Michael Boatwright and Trayvon Newsome, were sentenced to life in prison during a hearing last month.

XXXTentacion, whose real name was Jahseh Onfroy, had just left Riva Motorsports on North Dixie Highway on June 18, 2018, with a friend when his BMW was blocked by an SUV that swerved in front.

Surveillance video showed that two masked gunmen emerged and confronted the 20-year-old singer at the driver’s window, and one shot him repeatedly. They then grabbed a Louis Vuitton bag containing $50,000 cash that XXXTentacion had just withdrawn from the bank, got back into the SUV and sped away.

Boatwright, Newsome, Williams and Allan were arrested after the killing. Boatwright was the shooter while Newsome was the second gunman. Williams was the ringleader and getaway driver, and Allen was in the SUV with them.

Although Allen had testified he participated in the robbery during the trial of the other three suspects, defense attorneys had accused Allen of being a liar trying to avoid a life sentence.