04/11/2007 at 05:00 PM EDT
Snoop Dogg entered into a plea agreement Wednesday that spared him prison time – for now – on gun and weapons charges.
"Snoop recognizes he got a great plea deal from prosecutors," said his attorney, Donald Etra. "He's going to make sure nothing interferes with keeping his part of the bargain. He's relieved and glad this case is behind him."
As part of the agreement, the rapper, 35, whose real name is Calvin Broadus, pleaded no contest in a Pasadena court Wednesday to gun possession by a felon and sale or transportation of marijuana. Snoop has a certificate for medical marijuana for migraine headaches, but the amounts found exceeded the legal limit.
Superior Court Judge Terry Smerling then issued the suspended prison term, which could be lifted – sending Snoop straight to prison – if the rapper gets in trouble with the law again. The judge also placed Snoop on five years' probation, ordered him to perform 800 hours of community service and prohibited him from affiliating with gang members.
Snoop was arrested Oct. 26
at Burbank's Bob Hope Airport after he was found with a handgun and marijuana in his car. A raid a month later on his Los Angeles home uncovered another gun, police say.
Because Snoop is a convicted felon – he was busted for cocaine trafficking in 1990 – he is forbidden from owning a gun for life.
This does not end the musician's legal problems. He also has a standing case in Orange County
for a felony charge of knowingly possessing a dangerous weapon for trying to board a plane while carrying a 20-inch collapsible baton in a computer bag. He faces up to three years in prison if convicted. Snoop pleaded not guilty, and his attorney says the baton was a movie prop.