The Democratic Party retained its century-long stronghold on the Virginia General Assembly yesterday as Republicans saw their numbers eroded with the defeat of a Northern Virginia GOP delegate.

Republican Del. Gwendalyn F. Cody of Fairfax was defeated by Democrat Leslie L. Byrne, a businesswoman and community activist who received about 55 percent of the vote.

The GOP also suffered a defeat in Rockingham County, where Republican Del. Phoebe M. Orebaugh of Rockingham County lost to Democrat Paul C. Kline.

Republicans picked up only one seat, the Prince William seat of retiring Democratic Del. Floyd C. Bagley, which J.A. Rollison III won narrowly. The Democrats lost one seat to an independent.

In what at first appeared to be the evening's greatest upset, Democrat Jeffrey J. Fairfield declared victory over Republican Del. Stephen E. Gordy of Fairfax. But a mixup by Fairfax County election officials over vote counts apparently resulted in an incorrect tally initially, and Gordy declared victory later in the evening.

With Gordy's victory, the new House of Delegates will be 65 Democrats, 33 Republicans and two independents. The net loss of one Republican seat was a setback for the GOP in a year in which the party had hoped to make at least modest gains in the General Assembly.

The loss was also a disappointment for the national GOP, which has targeted control of state legislatures as a key point in its strategy to win a majority in the House of Representatives. State legislatures will control congressional redistricting after the 1990 census.

Republicans had targeted several Democratic delegates, particularly in Northern Virginia, but with no success.

Democratic Del. Bernard S. Cohen, an Alexandria attorney, fought off an aggressive challenge by Republican Anne H. Moore, a former congressional aide who outspent Cohen 2 to 1.

Del. Gladys B. Keating of Fairfax won reelection against Republican Edith L. Stratton in a race that Fairfax GOP officials had predicted would be close.

Del. Dorothy S. McDiarmid of Fairfax coasted to an easy victory, apparently assuring Northern Virginia an influential position in the 1986 General Assembly. McDiarmid is in line to become chairman of the powerful House Appropriations Committee, which decides how state money should be distributed among various regions and programs.

Of the 100 House of Delegate seats, only 41 were contested. Fifteen of those contested races were in Northern Virginia. The other six Northern Virginia delegates had no challengers. Members of the state Senate were not up for reelection this year.

Fairfax County GOP chairman Bentin K. Partin, commenting on the Republican losses, said, "The top of the ticket is really having an impact on all of these races . . . . They the Democrats have really . . . carried the day."

T. Farrell Egge, a Republican supervisor from the Mount Vernon District of Fairfax County, said the election results "look pretty disastrous to me." Egge added, "We found at the precincts there was a dearth of organization at the very basic level . . . . I don't know that we identified who the favorable voters were so we could get them to the polls. The numbers are mind-boggling."

"We've got to recognize that we've got to make some changes," said Richard A. Viguerie, the conservative direct-mail expert who tried unsuccessfully to get the GOP nomination for lieutenant governor. "The Democrats won on our issues," including crime and economic growth, he said.

Viguerie said the GOP should have been harder on the Democratic incumbents. "The Robb administration got off rather easy," he said.

He compared the loss in Virginia this year to President Ford's loss to Jimmy Carter in 1976, which the Republicans were able to turn around four years later with Ronald Reagan's victory.

"It was dark in 1976; it's dark now," said Viguerie. "I think we will have our greatest victories within a few short years if we copy the Republican model nationally and use it in Virginia."

At Fairfax GOP headquarters, the mood was low key as knots of party workers stood analyzing the results.

Fairfax County Board Chairman John F. Herrity said, "There are a lot of people who are not here who are at home crying." Herrity added that the Democrats had succeeded in getting their voters out, despite poor weather.

In addition to the statewide problems, Partin said that Cody was hurt by the fact that "she was on a hit list. The liberal NOW National Organization for Women group just can't stand a relatively conservative woman."

Cody has sparred with women's groups and liberals over her opposition to abortion.

But Byrne disagreed. She said the key factor in her victory was a newspaper poll earlier this year that rated Cody as the least effective of the 100 delegates. "It the poll was an issue," said Byrne. "The people were looking for someone to more closely represent their views, and I was it."

Byrne, arriving at a victory party in Fairfax for Democrats, greeted her husband Larry, who embraced her and exclaimed: "We did it, lady."

Cody, in her concession speech, said, "You win some and you lose some . . . . We had a campaign that was targeted by the Democrats from the beginning."

The evening's greatest suspense in the local races was over Fairfax County's 37th District, where attorney Fairfield, a 34-year-old political newcomer, ran a close race with two-term Republican incumbent Gordy, 65.

Republicans had dismissed Fairfield's candidacy, and even Democrats had given him little chance of winning.

Meanwhile, at the Fairfax Democratic headquarters, the crowd was jubilant.

One spectator, Clara Beyer, 93, grandmother of Donald Beyer Jr., the Northern Virginia campaign manager for newly elected Gov. Gerald L. Baliles, was particularly pleased.

"That a woman and a black could be elected in the state of Virginia is absolutely amazing," she said.

Democrats will hold a 12-to-9 edge in the Northern Virginia delegation to the House of Delegates.

Vivian Watts, who won her bid for reelection in Fairfax handily, said, "It gives more credibility in a legislature that is 2-to-1 Democratic.

"There will be a much more cooperative atmosphere" in the delegation, Watts said. "The teamwork aspect should really improve."

Of the 21 delegates from Northern Virginia, six were unchallenged, including five Republicans: Vincent F. Callahan Jr., James H. Dillard II, Robert K. Cunningham and Frank Medico -- all of Fairfax -- plus Harry J. Parrish of Prince William County.

Northern Virginia Republicans interpreted these unchallenged GOP seats as a sign of the party's growing strength in the region.

One Northern Virginia Democrat, Mary A. Marshall of Arlington, was unchallenged.

Independents picked up the Hampton seat held by retiring Richard M. Bagley, who is not related to Floyd Bagley.

Richard Bagley, who is weighing a gubernatorial bid in four years, was succeeded by independent Mary T. Christian.