The most divisive and bitterly contested judicial election in the memory of most Virginia legislators is expected to take place in the coming week as General Assembly Democrats choose between James. M. Thomason and Albert H. Grenadier to be a Circuit Court judge in Alexandria.

As a recent majority leader of the legislature's House of Delegates, Thomson ordinarily would be a shooin. But his record as an ardent segregationist and unrelenting foe of the federal Equal Rights Amendment has cost him the crucial backing of Alexandria's bar association and both Democratic delegates from his city.

With the endorsement of the bar and his home city delegates, Grenadire ordinarily would be a shoo-in. But Thomson's ties to both House and Senate Democrats after 22 years as a legisltor have produced a contest so close that supporters of both candidates are not yet willing t demand a decisive caucus to choose the winner.

The judgeship will be decided by separate, secret ballot votes of the 77 House and 34 Senate Democrats meeting in caucuses whose decisions all members are pledged to support in a formal vote on the floor.

As the General Assembly adjourned for the week last Friday, Del. Richard R. G. Hobson (D-Alexandria) declined to say whether he has won commitments for Grenadier from a majority of House Democrats.

In the Senate, where Grenadier's campaign is being managed by Sens. Clive L. DuVal and Joseph V. Gartlan, both of Fairfax, DuVal said, "We don't have the clear majority yet that would lead us to seek a meeting of the caucus."

Thomson's supporters seem equally uneasy about pressing for a vote. House Democratic Caucus chairman chairman C. Hardaway Marks of Hopewell apparently adopted a strategy last week of waiting for a Senate Decision in the hope that a Thomson victory there would dissolve the reluctance of House Democrats to oppose their two Alexnadria colleagues, Hobson and Elise B. Heinz.

The vote counts and strategic maneuvering by both sides have produced an absorbing political drama that has begun to overshadow major legislative issues. Influential law makers from throughout the state, who nomrally would stand clear of a local judgeship squabble, have been drawn into this one.

The issue is Thomson. Grenadier is a little-known establishment lawyer who, for the second time in five years, finds himself caught in a political quagmire in his quest for a judgeship.

In 1973, he was endorsed by the bar and elected by the House caucus only to be blackbalaled in the Senate by the former law partner, former state Sen. Leroy S. Bendiheim, in an action bitterly remembered by many of Grenadirer's supporters.

Now Grenadier finds himself buffeted by a backlash in the assembly against what many members regard as unfair attacks on Thomson by blacks, women's rights organizations and newspaper editorials.

Sen. Adelard L. Brault, the Senate majority leader from Farifax, refuses to discuss his vote even with other senators, but the moderate Senate leader is sharply critical of the attacks on Thomson.

"Both men are qualified to be judges," he said in an interview. "There is no question about it. But the criticism of Jim has been very unfair. There is no doubt in my mind that he could render fair and impartial judgments in any case."

Despite Brault's belief in Thomson's fitness for the bench, the former Legislator's support for racial segregation -- restated as recently as a 1971 election campaign -- makes him unfit in the eyes of Sen. L. Douglas Wilder (D-Richmond), the state's only black senator.

Wilder warned in an interview that Democratic support for Thomson, and for a list of all-white candidates for four federal judgeships in Virginia, could lead to defections by black Democrats in coming elections.

Referring to recent supprot of Republicans by some conservative Democratic officeholders, Wilder said: "We, too, can wear our party label, keep our seniority and then be as loud or quiet as we want to be for Democratic candidates. We can play that game, too. I learned it well from ny masters."

Fear of black voter reaciton in this General Assembly election year clearly is a factor working against Thomson. It is demonstrated by this story related Friday by a Northern Virginia senator:

A conservative Democratic senator told the Northern Virginian that he had promised Sen. Peter K. Babalas (D-Norfolk) that he would vote for Thomson. When the Northern Virginian warned him that "black groups in your district are going to give you a lot of trouble on this one," the other senator thought it over and went back to Babalas for a release of his commitment.

Thomson's stand against the ERA -- A STAND THAT CONTRIBUTED TO HIS House reelection defeat in 1977 -- is considered less of a factor in he judgeship contest. The Virginia legislature has repeatedly refused to ratify the ERA and few members equate opposition to it with discrimination against women.

Del. Clinton Miller, Shenandoah Valley Republican with close ties to many Democratic delegates, said he detects strong support for Thomson and no concern over feminist criticism among most Democratic legislators.

"Jim Thomson worked for the equal rights amendment to the state Constitution," he said. "He worked to purge the code of references to gender. He worked for equal pay provisions. There is no way you can say his opposition to this federal amendment means he would discriminate against women."

Nevertheless, one Democratic senator bases his support of Grenadier largely on his feeling "that the Democratic caucus should not appear to turn our backs on feminists and blacks." While this senator said he is satisfied with Grenadier's qualifications, he could not remember his name.

Although it is not uncommon for the assembly to ignore bar association recommendations, it is rare that the wishes of the local legislators, when they are united, are not observed.

Grenadier backers are confident that few of Northern Virginia's 27-member delegation will vote for Thomson, their influential legislative leader only two years ago.

With Brault sworn to a self-imposed silence on the judgeship, Grenadier's supporters are fearful only that Sen. Omar L. Hirst might become a Northern Virginia advocate for Thomson in the Senate caucus.

Hirst, of Fairfax County, is retiring from elective politics after this session as the senior legislator from the Washington suburbs. He has declined to say anything about the Alexandria judgeship delegates with liberal views and from a region regarded as suspect by many legislators from around the state, the fight for Grenadier may be costly.

"It's hurting them with the Houe leaders that want Jim," an assembly insider said. A Northern Virginia delegate who is sticking with Hobson and Heinz was asked if they were spending a lot of capital to beat Thomson in the caucus. "They didn't have much capital to begin with," he replied.