Getty

Kodak Black Gets 46 Months Behind Bars ... in Federal Gun Case

Kodak Black could spend the next 46 months behind bars in his federal gun case ... TMZ has learned.

The rapper's attorney, Bradford Cohen, tells TMZ ... Kodak's been sentenced to nearly 4 years in prison after he pled guilty in his federal gun case back in August. Kodak's also been sentenced to 3 years of supervised release.

It's a bit of a break considering prosecutors wanted 96 months after Kodak was involved in a fight behind bars which resulted in a prison guard getting hurt.

As we reported ... as part of Kodak's plea agreement, prosecutors said they would push for a lighter sentence because Kodak had been cooperative. He initially faced a maximum of 10 years after pleading guilty to 2 counts of knowingly making a false and fictitious written statement in connection with the acquisition of a firearm.

Kodak had been in federal custody since his arrest in May. He had wanted to be let out while the case unfolded but a judge denied his request for bail after calling him a danger to the community.

The rapper had been arrested at the Rolling Loud festival on arrest warrants stemming from his indictment.

Click here for info about our online advertising practices.