Atlanta (CNN) -- Rapper Gucci Mane will serve 39 months in prison after pleading guilty Tuesday to a federal firearms charge.
The plea agreement worked out with prosecutors saves Gucci Mane, 33, whose real name is Radric Davis, considerable time behind bars.
He was facing up to 20 years in prison and a fine of up to $500,000 on two counts of possessing a firearm as a felon after a pair of September incidents in which he reportedly showed a gun and threatened police.
Both came on the same week that Atlantic Records reportedly dropped his recording contract.
"On September 12, 2013, Davis, who was a felon at the time, was found in possession of a firearm," a federal prosecutor's news release said. "Then, just two days later, on September 14th, he again possessed a firearm different from the earlier gun. On both occasions, Davis displayed the loaded firearm, acted erratically, and made threats to individuals, including police and his attorney."
Davis has had numerous brushes with the law.
In 2012, Davis was arrested for hitting a man over the head with a champagne bottle at an Atlanta nightclub. The man told police the incident occurred after he tried to strike up a conversation with the rapper.
In 2010, he was arrested in Atlanta for violating a number of traffic laws, but the charges were dismissed.
In 2005, Davis was charged with murder in the shooting death of a man, but the charge was dropped because of insufficient evidence.
"The criminal history of the defendant, Radric Davis shows a complete and utter disregard for the lives of others as well as for their personal pursuits," Aladino Ortiz with the Bureau of Alcohol, Tobacco, Firearms and Explosives said Tuesday.
Sentencing is scheduled for July 28.
CNN's Eliott C. McLaughlin and Vivian Kuo contributed to this report.