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.
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.
Jay-Z and Meek Mill have partnered with the owners of the New England Patriots and Philadelphia 76ers, among others, to launch the Reform Alliance
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.
Reform founders: Jay-Z with Patriots owner Robert Kraft, the 76ers' Michael Rubin, Meek Mill, Michael Novogratz, Clara Wu Tsai, Daniel Loeb and the group's CEO Van Jones
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".
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.