In a first-of-its-kind ruling, a federal judge in Boston has ordered Massachusetts authorities to provide a taxpayer-funded sex-change operation for a transgender prisoner.

Chief U.S. District Judge Mark Wolf said he based his ruling on the recommendations of doctors at the commonwealth's Department of Correction who prescribed sex-reassignment surgery as "the only form of adequate medical care" for Michelle Kosilek.

Kosilek,...