R. Kelly Allegedly Attacked In Jail...

R. Kelly got a taste of jailhouse justice -- a frustrated inmate went on the attack and jumped Kelly in his cell ... TMZ has learned.

Federal law enforcement sources with direct knowledge tell us the incident recently went down inside the Metropolitan Correctional Center in Chicago where Kelly was sitting on his bed when another inmate walked in his cell and started punching the crap out of Kelly.

Our sources say the inmate went on the attack because he was angry about the detention facility being placed on lock down a couple of times largely due to Kelly protesters outside the jail.

We're told the fight didn't last long, and it's unclear if another inmate or guards broke it up. Our sources say Kelly was examined by a doctor, who determined the singer was okay ... no broken bones or serious injuries.