Lenny Dykstra claims he was beaten within an inch of his life while in custody at L.A. County Jail ... and the former MLB great says his attackers were corrupt cops ... this according to legal docs obtained by TMZ Sports.
Dykstra -- who was locked up for bankruptcy fraud -- is suing L.A. County claiming back in April 2012, roughly 6 sheriffs entered his cell, yanked him from his bed and began beating him for no reason.
Dykstra says he was punched in the head, face, nose, mouth, arms, legs and body -- and his head was slammed into a wall. He also claims he was kicked and beaten until he was "barely breathing."
In his lawsuit, Lenny claims he suffered serious injuries -- including bruises, scabs and some of his teeth were knocked out.
And get this ... Lenny claims corrupt law enforcement officers prevented him from getting proper medical attention after the beating -- instructing nurses and doctors to NOT do their job.
Dykstra also says the Captain of the jail had it out for him -- and had him labeled as crazy and told the medical staff to forcibly medicate him with drugs to discredit him.
And for theatrical flair, Dykstra, in his suit, compared the cops to the corrupt officers in the Stallone flick "Copland" ... which, for the record, was NOT Sly's finest work.
We reached out to the Sheriff's Dept. for comment -- so far, no word back.