Early one morning in February, a guard clanged on the door of David Mustiga’s jail cell on Rikers Island. Soon, the 43-year-old was shackled and put on a bus to Bellevue.

Rikers detainees often struggle to get even rudimentary medical care. But Mr. Mustiga and 10 other prisoners have undergone elective bariatric surgery at Bellevue, often spending weeks in the hospital.

Even in the best conditions, recovering from bariatric surgery is tough. Trying to recuperate in jail, where detainees have little control over what they eat or how fast they eat it, is especially difficult.

Mr. Miller said patients from Rikers were “screened and assessed like all others” and were kept at Bellevue until they were ready to eat the types of food that were available at the jail.

Mr. Mustiga, who was later convicted of drug trafficking, weighed more than 300 pounds and had high blood pressure. He had been excited months earlier when a staff member at the Rikers medical clinic first told him about the benefits of bariatric surgery. He said no one had warned him about the challenges of recovering while incarcerated.

Mr. Mustiga received a pamphlet from Bellevue advised him to try a Zumba dance class.Credit…via David Mustiga

When Mr. Mustiga boarded the bus to Bellevue, he thought it was for a brief visit to get bloodwork in preparation for surgery. Instead, he was admitted to the hospital’s locked prison ward and placed on a liquid diet.

There, he met another patient waiting for bariatric surgery, Luis Perez. The men bonded over their dieting ordeals and teamed up to steal scraps from their neighbors’ hospital trays.

Mr. Perez, who was awaiting sentencing for drug possession, had surgery first. Afterward, he told Mr. Mustiga that the pain was worse than when he had been hit by a car and lost his arm above the elbow.

Mr. Mustiga panicked. He said he had tried to back out of the surgery, but a doctor told him that this was his only shot at getting the procedure and that if he didn’t follow through, he would be sent back to the jail immediately.

Mr. Mustiga said he often used the same pressure tactics on his drug customers. “Tell someone it’s their last shot, and they find their wallet pretty quickly,” Mr. Mustiga said.

He decided to have the operation.

After surgery, patients are supposed to consume small, protein-rich meals.

Luis Perez said he suffered complications after his surgery.Credit…via Annette Martínez

Back at Rikers, Mr. Mustiga bartered cigarettes for protein powder. He reviewed a Bellevue pamphlet outlining dos and don’ts after surgery. It suggested that he eat nonfat Greek yogurt or drink eight cups of Crystal Light. Exercise tips included trying a Zumba dance class.

Mr. Mustiga wasn’t getting proper nutrition. He said he lost more than 100 pounds in less than six months — a rate of weight loss that can be dangerous. His hair fell out in clumps, and his medical records show he was receiving iron supplements for anemia.

This summer, Mr. Perez was transferred to Franklin Correctional, a prison near the Canadian border, to serve a four-year sentence.

During a visit in August with two Times reporters, Mr. Perez’s skin was sallow. He said he was not getting enough protein and could not eat without vomiting. He worried the surgery had made him a target in prison, where size matters for protection.

Two months later, Mr. Perez was badly beaten. He said his attackers stole the protein powder he had been saving up.