WASHINGTON (CNN) -- A former Army commander who underwent a sex change operation was discriminated against by the U.S. government, a federal judge ruled Friday in an important victory for transgenders claiming bias in the workplace.

Diane Schroer won her federal lawsuit against the Library of Congress after officials backed out of a 2005 job offer when told of her intention to become a transsexual. At the time of the job interview for a position as a senior terrorism research analyst, David Schroer was a male. He had been a onetime Army Special Forces commander.

U.S. District Court Judge James Robinson said Schroer's civil rights were violated.

"The evidence established that the Library was enthusiastic about hiring David Schroer -- until she disclosed her transsexuality," Robinson wrote. "The Library revoked the offer when it learned that a man named David intended to become, legally, culturally and physically, a woman named Diane. This was discrimination 'because of ... sex.' "

The judge will later rule on what financial damages Schroer is due.

"It is especially gratifying that the court has ruled that discriminating against someone for transitioning is illegal," said Schroer in a statement from the ACLU, which represented her in court.

"I knew all along that the 25 years of experience I gained defending our country didn't disappear when I transitioned, so it was hard to understand why I was being turned down for a job doing what I do best just because I'm transgender. It is tremendously gratifying to have your faith in this country, and what is fundamentally right and fair, be reaffirmed."

After Schroer had retired from the military, she applied for a job at the Library of Congress. Court records show that Schroer, then a male, took her future boss to lunch to outline her transition to a female, as she planned to present herself as a female on her first day of the job.

Schroer testified that on the day after the lunch, the job offer was rescinded, and she was told she wasn't a "good fit" for the library.

The ACLU said the ruling sends a "loud and clear" message to employers against firing or refusing to hire someone for changing their gender.

There was no immediate reaction from the library, which had claimed at trial that transgender people are not covered under federal anti-discrimination laws.