A few days after Ramon Fabian arrived at the Ulster Correctional Facility on the southern edge of the Catskill Mountains last year, a guard conducting the morning head count yelled at him to shut up.

Inmates at Ulster, a medium-security New York State prison, are required to stay in place and keep their voices low during the count. Mr. Fabian, who was serving a one-year sentence for a drug conviction, had been talking to another inmate, but he said in a recent interview that he thought he had been following the rules.

After the count was over, the guard escorted him past a set of double doors out of view of other inmates and the prison’s electronic surveillance cameras. Mr. Fabian said the officer, Michael Bukowski, a seven-year veteran, had then ordered him to face the wall and brace himself in the “pat-frisk” position, arms outstretched and legs spread. As he did so, Mr. Fabian recalled, he looked down and saw the toe of a boot swinging up between his legs.

He saw a flash of light, felt a piercing pain and collapsed. “He told me to get up, but all I could do was crawl back to my cube,” Mr. Fabian, who is now 21, told investigators later. He lay on the floor in his cubicle in the prison’s dormitory, groaning and crying, for almost an hour before hobbling to lunch. In the mess hall, a sergeant sent him to the prison’s medical unit. He was soon loaded into a van and driven 80 miles north to a hospital in Albany. Doctors there performed emergency surgery, removing part of his right testicle.