Theodore C. Gregory, a Loudoun County horse trainer, was gripped by an irresistable impulse and was temporarily insane when he shot his wife's lover to death in August 1980, defense lawyers argued today as Gregory's first-degree murder trial opened here.

Publicity about the slaying of Howard B. LaBove as he made love to Gregory's estranged wife at a secluded cottage in Middleburg's hunt country prompted Circuit Judge Carleton Penn to shift the trial to this small town about 80 miles west of the District of Columbia.

Gregory, 31, was convicted two years ago of trying to murder his wife, Monique, on the same night LaBove was killed. A retrial ended in acquittal. Gregory could be sentenced to 20 years to life in prison if convicted of LaBove's slaying. An accompanying firearms charge carries an automatic one-year prison term on conviction.

In opening remarks today, defense lawyer Blair Howard of Alexandria characterized Gregory as "acting like a robot" and "obsessed with the idea of getting his wife back" after the couple's estrangement in the summer of 1980.

The lawyer said friends of the couple met three weeks before the shooting to discuss having Gregory committed for psychiatric care.

Loudoun prosecutor James E. Mechling, in his opening statement, said Gregory burst into LaBove's bedroom as the couple made love and shouted, "I'm going to kill you, bitch," or "I'm going to kill you both."

Howard, however, pointedly referred to testimony by Monique Gregory in an earlier trial that the stronger term was used, indicating Gregory had followed the two home from a party at a Middleburg restaurant intending to kill his wife, not her lover.

The Gregorys were divorced this spring and Gregory was indicted by a Loudoun grand jury in LaBove's death shortly afterward. The divorce means Gregory's ex-wife now may testify against him.

Gregory sat tight-lipped today, often staring at the floor, as the trial proceeded in the tiny, second-floor courtroom of Rappahannock County's red brick, early 19-century courthouse. His former wife, now Monique Dana, is expected to testify for the prosecution on Wednesday.

Also scheduled to testify are psychological experts on both sides. Defense lawyer Howard pictured his client today as dazed on the fatal night of Aug. 20--a man, Howard said, whose first shot went into LaBove's bedroom floor as the 6-foot-4 LaBove lay in bed only six feet away.

"The issue is whom he came in there to shoot and what efforts he made to shoot anybody," Howard contended.

Howard predicted that even a Virginia state psychologist called by the prosecution will testify that the bedroom scene that confronted Gregory "was provocative. No scene could be more provocative."

Both sides said today the shooting occurred as LaBove and Gregory wrestled on the cottage's living room floor. Monique Gregory was injured by broken glass as she pounded, in the nude, on the door of a neighboring tenant house for help.

During jury selection this morning, Judge Penn's quizzing of prospective jurors included the question: "Do you believe a husband separated from his wife for several months is justified in killing a man he found in the act of sexual intercourse with his wife in that man's house?"

Although most answered no, one man answered affirmatively. "I'd have to give it serious thought," he said before he was seated as a juror.