Rapper Young Thug pleaded guilty in Atlanta, Georgia to gang, drug and gun charges and will be released from jail, though he could be put back behind bars if he violates the terms of his sentence.

The 33-year-old Grammy winning artist, whose given name is Jeffery Williams, entered his pleas without reaching a deal with prosecutors after negotiations between the two sides broke down, lead prosecutor Adriane Love said.

That left the sentence completely up to Fulton County Superior Court Judge Paige Reese Whitaker.

The judge imposed a sentence of 40 years, with the first five to be served in prison but commuted to time served, followed by 15 years on probation.

If he successfully completes that probation without any violations, another 20 years will be commuted to time served.

But if he violates the conditions, he will have to serve those 20 years.

Young Thug pleaded guilty to one gang charge, three drug charges and two gun charges.

He also entered a no contest plea to another gang charge and a racketeering conspiracy charge, meaning that he decided not to contest those charges but can be punished for them as if he had pleaded guilty.