A 22-year-old carpenter's assistant went on trial in Fairfax County yesterday as, according to legal observers, the first man in Virginia to be tried on a charge of raping his wife.

Prosecutors said that if the man is convicted, the case could have major social implications on the way the state's courts address the issue of rape in marital cases.

The man's wife, 20, testified in Fairfax County Circuit Court yesterday that her husband raped her in a locked apartment Oct. 17 while friends stood outside listening to her screams and sounds of a struggle inside.

Her husband has denied the charges, saying they were engaged only in foreplay, to which his wife consented.

Judge Richard J. Jamborsky yesterday turned down for the second time defense attorneys' efforts to quash the rape indictment. He said legal arguments contending that a husband cannot rape his wife are "repugnant to the idea of personal liberty."

But Jamborsky ruled that the guidelines in such a case are narrow: Rape can be alleged only in cases where the man and woman have been living apart.

The couple testified they have not lived together since Nov. 9, 1981.

If Jamborsky's ruling were extended to all married couples, "you would open the floodgates for totally unproveable cases," said Thomas E. Gallahue, the assistant commonwealth's attorney prosecuting the case. "It makes a great deal of difference if the husband and wife have been separated for a long time."

In court yesterday, husband and wife gave the six-man, six-woman jury different versions of the Oct. 17 incident, although they generally agreed on events that led up to it.

The woman and a date were at a friend's apartment awaiting other friends, the woman testified, when she heard someone knocking on the apartment door and saw her husband through the door's peephole. She testified she was too frightened to let him in, and minutes later he scaled a series of balconies to the sixth floor apartment and began banging on the sliding-glass balcony door.

At that point, the woman and her husband both testified, she let her husband in and he argued with her date, eventually asking him to step outside "to fight."

"And then it was almost like what you'd expect to see in a movie or comedy," said prosecutor Gallahue in his opening statement. The woman's date "made the mistake of going out the door first. The husband slammed the door and locked it behind him."

The wife said her husband grabbed her around the arms and shoved her into the bedroom, ripping off her clothes and forcing her to have intercourse.

She testified she heard her friends banging on the locked door. "The more they pounded, the more I screamed," she said.

The husband testified the woman willingly engaged in foreplay with him and began screaming only after the two began hurling accusations at each other as to which friends the other had been sleeping with.

The husband said he was shocked when the woman told friends he had raped her: "I wondered why someone I loved this much would turn on me and stab me in the back," he told the jury.

Defense attorneys attempted to prove that the couple had been friendly with each other since the separation that ended their 1 1/2-year marriage. The husband said his wife agreed to have sexual intercourse with him several times during the nine-month period. The woman denied that was true.

Defense attorneys surprised prosecutors late in the testimony when they produced six snapshots of the woman, which they described as showing her "in various states of undress and poses . . . "

The husband claimed he took the photographs after he and his wife had separated. The prosecution charged the photographs had actually been taken two summers ago while the couple was still living together. The prosecution said it was trying to locate witnesses last night to support that argument. Those witnesses, if found, will testify when the trial resumes at 9:30 a.m. today.