3:54 PM PT -- Young Thug could be home very soon ... he was just sentenced and may not have to serve any more time behind bars if he successfully completes 15 years of probation.
On Thursday afternoon, Judge Whitaker imposed the sentence, which amounts to 40 years in total.
It's a bit complicated, but here's the gist -- he was given time served for 5 of the years plus 15 years on probation.
There is also a backloaded 20-year prison sentence that could kick in after probation ... but he'll only have to serve that time behind bars if he doesn't successfully complete his probation term.
If he keeps his nose clean during probation, the judge said that part of the sentence would be commuted.
His lawyer Brian Steel also requested he still be allowed to associate with co-defendants, his brother Quantavious "Unfoonk" Grier and Sergio "Gunna" Kitchens, in order to continue his rap career.
The state had been recommending Thug serve at least 25 years in prison, but it appears the judge went in a very different direction.
Young Thug decided to enter a guilty plea in his YSL RICO case ... which will bring an end to his part in what has become the longest trial in Georgia history.
On Thursday -- Halloween '24 at that -- Thug switched his original plea he made in 2022 and pleaded guilty to his role in criminal street gang activity.
He also pleaded no contest to conspiracy to violate the RICO Act and leading a criminal street gang.