Police officers raided his home in Los Angeles and took him into custody after discovering the firearm.
Although America has lenient gun laws, Soulja Boy is banned from owning one as part of his probation following an earlier arrest.
The rapper was detained in 2014 for carrying a loaded gun after police pulled over the driver of his car on suspicion of ignoring a stop sign.
The 26-year-old rapper, whose real name is DeAndre Cortez Way, was behind one of the biggest dance crazes of the last 10 years with his debut single Crank That (Soulja Boy) in 2007.
The moves, in which you shake your arms alternately to the right and left, helped the song get to number one in America.
It became the first single to be downloaded three million times - a record which has since been beaten.
After several follow-up hits, Soulja Boy has struggled to match his earlier success.
He's recently been starring on reality television and promoting online poker.
Although it's unclear why police decided to enter his house on Thursday, entertainment website TMZ said officers were responding to a threat that the rapper allegedly made online.