Meek Mill has pleaded guilty to a misdemeanour 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.
I’m extremely grateful that my long legal battle is finally behind me and I appreciate that it has sparked a much-needed discussion about probation reform and the inequalities that exist within our two Americas. pic.twitter.com/noDEA1HaRd— Meek Mill (@MeekMill) August 27, 2019
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.
The 32-year-old set up the Reform Alliance with Jay-Z and two American sports team owners.
The group's "mission" is to "dramatically reduce the number of people who are unjustly under the control of the criminal justice system, starting with probation and parole".
I have always told the truth — that as a teenager, who saw many around me die from senseless gun violence, I carried a gun for protection. I take responsibility for that and – in conjunction with my work on the @REFORM Alliance –— Meek Mill (@MeekMill) August 27, 2019
I’ll continue to use my platform to make communities safer and reform our criminal justice system. I want to express my gratitude to all of my supporters, especially JAY-Z, Desiree Perez, Michael Rubin, my legal team and everyone else who stood by me throughout the years.— Meek Mill (@MeekMill) August 27, 2019
Examples of parole violations that can land people back in prison range from being late to appointments with parole officers or missing a curfew, to things more specific to the crime that was committed - like failing to attend an Alcoholics Anonymous meeting.
More than six million people can currently count themselves as part of the "correctional population" of the USA - which includes people in prisons and local jails, but is mostly made up of the more than four million people on probation or parole, according to Bureau of Justice statistics.