R. Kelly's alleged attacker just ID'd himself in court docs, claiming he’s the one who beat up Kelly behind bars ... and he has gang ties and murders on his record.
Jeremiah Shane Farmer filed legal docs, obtained by TMZ, claiming he’s the pissed off inmate who went on the attack and jumped Kelly in his jail cell.
In the docs, Farmer claims "the government made me attack" Kelly -- although he doesn't explain why -- and says he pulled it off in hopes of shedding light on government corruption. As for what the "corruption" is ... he feels he was done dirty by the justice system.
TMZ broke the story ... Kelly got a taste of jailhouse justice last month inside the Metropolitan Correctional Center in Chicago.
Lake County Sheriff's Dept
Farmer's admission is part of legal docs filed in a federal appeals court. Records show he's representing himself and is being housed at MCC just like Kelly.
R. Kelly's attorney, Steven Greenberg, tells TMZ Farmer is indeed the one who attacked the singer.
As we reported ... our federal sources and Kelly's attorneys said the inmate went on the attack because he was angry about MCC being placed on lockdown a few times, largely due to Kelly protesters outside the jail.
Farmer also included a Bureau of Prisons incident report in his filing, which says the alleged attack happened around 9:45 AM Aug. 26. The report says Farmer appeared to repeatedly punch Kelly in the head and torso, with a prison employee using pepper spray to end the alleged assault.
The U.S. Attorney’s Office for the Northern District of Indiana says Farmer is a Latin Kings gang member, and he was convicted last year after a jury found he beat 2 men to death with a hammer as part of a racketeering conspiracy.