They keep the prisoners locked up — but apparently can’t keep it in their pants!

Corrections officers and supervisors are having “rampant” sex with each other both on and off the job at the city’s jails on Rikers Island, a new bombshell lawsuit by one of those randy officers claims.

Corrections Officer Tomara Bryan’s discrimination complaint claims that female supervisors verbally and physically abused her, and unfairly disciplined her after learning she was having a consensual affair with a married warden named Emmanuel Bailey.

And she claims the Department of Correction retaliated against her after she made a complaint about the “rampant inappropriate sexual acts taking place on an off the job” between corrections officers and their bosses.

Bryan’s lawsuit says those female Department of Correction bosses routinely discriminate against female subordinates for such intra-jail sexual liaisons — but let the guys involved in the affairs off the hook.

“Consensual sexual relationships between and among uniformed members of various ranks both on and off the job was rampant within the DOC,” Bryan said in her Bronx Supreme Court action filed Monday.

The suit comes nearly seven months after Bailey was arrested on assault and harassment charges after Bryan told cops he had beaten her up during their affair. According to a criminal complaint, Bailey allegedly punched Bryan in the face, kicked her in the stomach, punched a hole in the wall of her Brooklyn apartment and threatened to kill her.

Bailey retired under pressure shortly before that arrest. Court records show Bailey pled guilty to disorderly conduct and received a conditional discharge, according to Brooklyn DA’s office.

At the time of his arrest, sources told The Post that Bailey’s wife — who also is a correction officer — allegedly began putting Bryan on dangerous assignments after learning her husband was hooking up with Bryan.

Bryan’s lawsuit claims that “DOC female supervisory employees engaged in a pattern and practice of discriminating and/or permitting discrimination against female uniformed members engaged in consensual sexual relationships with male uniformed members based on a perception or belief that women are responsible for the initiation of these sexual relationships.”

But those same women bosses “do not treat male DOC employees engaged in consensual sexual relationships with female DOC employees in the same negative manner as they treat the females engaged in such relationships,” the complaint said.

In fact, the suit claims, DOC regulations bar supervisors from “engaging in intimate relationships” with members of the Corrections Department.

But DOC bosses “knew or should have know that Warden Bailey was frequently violating DOC regulations engaging in intimate relationships with female members of DOC” — even before Bryan began having an affair with him, her suit said.

The suit charges that in around July 2010 — after Bryan’s relationship with Bailey became known — Bryan was subjected to “verbal and physical abuse. derogatory comments and unjustified disciplinary actions,” in addition to being given “dangerous and/or undesired assignments” and “subjected to a bogus ‘random’ drug test.”

She claims she “suffered severe personal injuries” including “emotional distress, pain and suffering, anxiety, depression, fear and other psychological trauma and injury” as a result of this treatment.

The DOC issued the following statement:

“We took Officer Bryan’s complaints seriously, looked into the issues she raised at length, and made repeated good faith efforts to address her concerns. There is no basis to support her claim that she was the victim of retaliatory action or discrimination by the Department of Correction.”