County officials say Keef, 17, has been taken to Cook County's juvenile detention center until his next court appearance, which will be Thursday.
Keef, real name Keith Cozart, is on probation for pointing a gun at Chicago police officers.
Judge Carl Anthony Walker found Cozart showed a "willful disregard" of the court and ordered him held until Thursday when the judge will conduct a sentencing hearing.
Prosecutors said Cozart violated his probation in June when he visited a gun range in New York. He was prohibited by the judge from having any contact with firearms. His attorney Dennis Berkson argued Cozart fired a rifle on private property as part of a promotional video. He said that didn't violate the spirit of the judge's order.
But Walker said it was no different than if Cozart handled a gun in a home. In that situation, he would have violated Cozart's parole, the judge said. Cozart, who was sentenced to 18 months probation in January 2012 for pointing a gun at Chicago cops, was handcuffed behind his back and taken out of the court Tuesday.
Cozart, who wore camouflage pants, a black-hooded sweatshirt and Timberland boots, did not address the judge or testify during the two-hour hearing.
In December, Cozart released a new album, "Finally Rich." He was in the news last summer after another Chicago rapper, Joseph "Lil JoJo" Coleman, was shot to death on the South Side.
Coleman and Cozart, who were affiliated with rival gangs, were engaged in a war of words on the Internet at the time.
Cozart hasn't been accused of any wrongdoing in connection with Coleman's killing.
The Sun-Times Media Wire contributed to this report.