An Alexandria federal judge, citing "willful, wanton and flagrant violations" of rulings he made in a sex discrimination suit against the Richmond, Fredericksburg & Potomac Railroad Co., held the railroad in contempt yesterday, and fined it $25,000.

U.S. District Judge Richard L. Williams issued an order compelling the company, which owns and operates the only railroad running between Washington and Richmond, to offer Sandra Jean Hylton the first available apprentice job as a locomotive engineer.

Williams also declared that if the company does not comply with his order by noon Friday, he will fine it $5,000 each day until it does. A company spokesman said it will abide by the ruling.

"I feel like this fight is finally won," said Hylton, 37, who last year won a suit in which she charged the RF&P with deliberately keeping women fron high-paying jobs as locomotive engineers.

"All I have ever wanted to be was an engineer. When they went around me, I knew I would have to tussle to get it," she said.

A lawyer for the railroad said that he was surprised by yesterday's ruling, and that the company does not feel it has violated any previous court decisions.

"Everybody on the railroad wants to be an engineer," said Fred Alexander, the railroad's attorney. "We've got people who know the rails backwards and forwards standing in line, so we feel we have a right to be selective."

Last August, Judge Williams found that the RF&P effectively barred women from becoming engineers by requiring that they have some locomotive experience. No women now work on the locomotives aside from one female engineer.

A month ago, the company posted a notice to all employes that said any candidate for apprentice engineer programs would need six months' experience on a locomotive.

But in his order yesterday, Judge Williams wrote that "this court held that there is no relationship between prior railroad experience and competency as a locomotive engineer."

When the suit was originally filed in March 1984, the RF&P had never employed a woman locomotive engineer at either its Richmond or Alexandria yards and none had ever been admitted to its 11-year-old apprenticeship program. In the last year, the company, which has about 800 employes, has hired one woman engineer.

According to the most recent statistics available from the Department of Labor, fewer than 200 of the nation's 35,000 train engineers are women.

"She loves the railroad," Alan Rosenblum, one of Hylton's attorneys, said of his client. "She simply wants to have the same job opportunities as the men have. She deserves that."

Hylton has been with the railroad for 13 years and has been trying to become an engineer for more than a decade. The average annual salary for an RF&P engineer is about $40,000. Hylton said she earns about $25,000 as a signal control operator.

Alexander said that the RF&P is in the process of appealing the initial court ruling, and that it also will appeal yesterday's contempt finding and fine.