The US Tax Court ruled yesterday that a Massachusetts woman should be allowed to deduct the costs of her sex-change operation, a decision that could have wide implications for transgender people.

Rhiannon O’Donnabhain, who was born a man, sued the Internal Revenue Service after the agency rejected a $5,000 deduction for approximately $25,000 in medical expenses associated with the sex-change surgery.

The IRS said the surgery was cosmetic and not medically necessary.

In its decision yesterday, the tax court said the IRS position was “at best a superficial characterization of the circumstances’’ that is “thoroughly rebutted by the medical evidence.’’

The legal group, Gay & Lesbian Advocates & Defenders, which represented O’Donnabhain, said the ruling could potentially affect thousands of people a year in the US who undergo similar operations.

“I think what the court is saying is that surgery and hormone therapy for transgender people to alleviate the stress associated with gender identity disorder is legitimate medical care,’’ said Jennifer Levi, a GLAD attorney.

IRS spokeswoman Michelle Eldridge declined to comment on the ruling.

In a 2007 interview with The Associated Press, O’Donnabhain said she underwent gender-reassignment surgery at age 57, after a tormented existence as a father, husband, Coast Guardsman, and construction worker.

She wrote off the $25,000 in medical expenses on her taxes, but the IRS disallowed the deduction, saying the procedure was not a medical necessity.

O’Donnabhain, now 65, said she brought the lawsuit in an attempt to force the IRS to treat sex-change surgeries the same as appendectomies, heart surgeries, and other deductible medical procedures.

“It is not OK for them to do this to me or anyone like me,’’ she said.

O’Donnabhain’s lawyers argued that because gender-identity disorder is a recognized mental disorder that is generally treated with hormones and surgery, the costs are legitimate medical deductions.

The tax court agreed.

“The evidence amply supports the conclusions that petitioner suffered from severe GID, that GID is a well-recognized and serious mental disorder, and that hormone therapy and sex reassignment surgery are considered appropriate and effective treatments for GID by psychiatrists and other mental health professionals who are knowledgeable concerning the condition,’’ the court said in its ruling.

An estimated 1,600 to 2,000 people a year undergo sex-change surgery in the United States, according to the Gay and Lesbian Medical Association.

The tax court said O’Donnabhain could deduct as a medical care expense the costs associated with treating her gender-identity disorder, except for the costs of breast augmentation surgery, because she had achieved breast enhancement through hormone treatments.

© Copyright 2010 Globe Newspaper Company.