Meek Mill has pleaded guilty to a misdemeanor gun charge, in a plea deal which ends a 12-year long case.
The US rapper was granted a new trial in July because judges ruled that his original trial in 2008 had credibility issues with the arresting officer.
The judge in the new trial decided the two years Meek Mill had already spent in prison was enough.
“I know this has been a long road for you and hopefully this will be the end of it,” said Judge Leon Tucker.
Meek Mill, whose real name is Robert Rihmeek Williams, said the whole case had been “mentally and emotionally challenging”, but that other people in the US also face similar ordeals.
He’d originally gone to jail in 2009 after being arrested on gun and drug charges.
He was released on parole after five months and given a 10-year probation period.
Probation is often given as a sentence instead of time in prison and can include conditions like being on a curfew or going to rehab.
Parole is when an inmate is released early from prison with similar conditions to probation.
In the last ten years, Meek Mill has become a platinum-selling artist while on probation.
A parole violation for suspected cannabis use resulted in a ban on touring, and then after failing to get his travel plans approved by the court he went to prison for five months in 2014.
The rapper was arrested again in August 2017 for reckless driving as he rode a dirt bike during filming of a music video.
Although the charges were later dropped, a judge ruled the arrest itself was a breach of his probation and he was jailed that November for up to four years.
He served another five months in jail before being released in April 2018 – and has since become a campaigner for criminal justice reform.