A Montgomery County judge granted a divorce yesterday to the wife of former Security and Exchange Commission enforcement director John M. Fedders, on grounds that Fedders was guilty of cruelty and "excessively vicious" conduct toward his wife during their 19-year marriage.

The 95-minute oral opinion by Circuit Court Judge James S. McAuliffe ended a bitter and protracted trial that revealed in painful detail how Charlotte Fedders suffered privately while her husband became a successful lawyer and a top official in the Reagan administration.

"When you put it all together, you have as classic a situation of cruelty . . . and as classic a situation of excessively vicious conduct as you are going to get," McAuliffe said.

After the ruling, in which Charlotte Fedders won full use of the couple's $300,000 Potomac home, custody of their five children and $1,500 a month in support, Fedders strode from the courtroom, head down, leaving his lawyer rushing to catch up.

Charlotte Fedders, who had sobbed gently during McAuliffe's ruling, appeared visibly relieved afterward. She was surrounded by several friends and left the court smiling with her attorney at her side.

Both the Fedderses and their lawyers declined to comment on the case.

McAuliffe described Fedders yesterday as a man who suffered from rapid mood swings. One moment, he would be shy and withdrawn. Then, "almost instantaneously," his mood and conduct would change, the judge said.

Drawing from Charlotte Fedders' testimony, McAuliffe cited beatings over the course of the marriage in which John Fedders had broken his wife's eardrum, wrenched her back and neck and given her a black eye.

In one episode of violence, McAuliffe cited testimony that Fedders had beaten his wife around the abdomen while she was pregnant and had said he didn't care if he "killed her and the baby."

In another, which McAulliffe called "startling to the court," the judge noted testimony describing how Fedders had exploded when his wife refused to remove her shoes in the house.

"On this occasion Fedders tried to throw her over the banister" and shook her by the hair while two children looked on, the judge said.

Although he acknowledged some of the violent episodes, Fedders claimed that his wife's versions of the incidents were exaggerated and strongly denied threatening to kill her.

Fedders also testified that he never intended to throw his wife over the banister and said he felt "forever remorseful" about injuring her neck during the incident. However, McAuliffe concluded that Charlotte Fedders' accounts were accurate.

In a legal memorandum filed last month, Fedders had asked the court to dismiss his wife's petition for a divorce and to order psychiatric counseling aimed at achieving a reconcilation.

The request was based on Fedders' contention that he and his wife had reconciled for three weeks in April. During that time, Fedders testified, they spent the night at his apartment and had sexual relations for the first time in two years.

But McAulliffe rejected the plea in his opinion, noting that Maryland law no longer recognizes the resumption of sexual relations as conclusive evidence of a reconciliation. He did, however, stipulate that Charlotte Fedders could not remarry for 12 months, at which time a final property settlement would be made.

The judge said that Charlotte Fedders had called off the reconcilation after three weeks and noted that the couple never had moved in together or had "announced to the world" that they had gotten back together.

"It was a trial run and only that, and it didn't work. She never manifested an attempt to forgive that which took place over many years," he said.

Fedders separated from his wife in 1983, but their divorce case gained national attention last Feburary when newspapers first published the details of the stormy marriage. He resigned his SEC position three weeks later.

At the time Fedders accepted the SEC appointment, he was earning more than $160,000 with Arnold and Porter, one of Washington's most prestigious law firms. He took a large salary cut to join the SEC, where he earned $73,000, and ran up huge bills trying to maintain his life style.

After his resignation, Fedders was hired by the firm of Miller, Cassidy, Larroca and Lewin, but McAuliffe noted yesterday that his salary had fallen from more than $6,000 a month to $781 a month.

Even so, the judge said he was obligated to support his family in their Potomac house and ordered him to increase payments for alimony and child support from $1,000 a month to $1,500 a month. Fedders also was ordered to pay the mortgage, utilities, taxes and half of the maintenance costs on the house.

"Financially, these two parties found themselves fighting on the top of a cliff. Instead of desisting, they went over the cliff, taking themselves and their children with them," the judge said.