Former Virginia House majority leader James M. Thomson is mounting a vigorous campaign here to win an Alexandria judgeship despite strong opposition from Northern Virginia groups.

His behind-the-scenes lobbying has surprised some state legislators and has upset supporters of Albert H. Grenadier, the lawyer who has been endorsed by the Alexandria Bar for the Circuit Court judgeship. One of Grenadier's backers said tonight that they had been "mousetrapped" into believing Thomson would withdraw from the race after winning rulings from two General Assembly committees that he was "qualified" to be a judge.

"He's decided to go for it," one Northern Virginia senator said of Thomson's decision to seek the judgeship despite opposition from Alexandria's Democratic legislative delegation and the city's bar association.

Thomson, according to the senator and other legislators, has been telephoning House and Senate members since Tuesday and urging them to support him over Grenadier, the choice of Alexandria's two Democratic delegates.

"Jim has a Spartan mentality," said one delegate. "He either wants to come home with his shield or on top of it."

Thomson, an influential legislator who served in the General Assembly for 22 years until he was defeated in 1977, has long been criticized by blacks and women as being unsympathetic to their concerns. They are among those most vehemently opposed to his campaign to be nominated to the bench vacancy created by the retirement of Judge Franklin P. Backus.

Thomson's push for the judgeship has thrown some members of Virginia's precedent-minded assembly into a quandary. The former House majorty leader has earned a lot of legislative IOUs, but assembly members traditionally bow to the rule of local courtesy in filling judgeships, respecting the wishes of the elected representatives of the jurisdiction in which a vacancy occurs.

State Sen. L. Douglas Wilder (D-Richmond) said today he was shocked by Thomson's campaign. "I consider this a preliminary breach of faith by the assembly leadership," he said. "I was assured by the majority leaders of both houses that Thomson did not want his name placed in nomination.

"They said he was devastated by the refusal of the bar association to endorse him and only wanted certification by the courts of justice committees," Wilder said.

That no longer seems to be the case, according to legislators here, one of whom said Thomson's "own ego" and "encouragement from people who, in the end, will desert him" are factors contributing to his judgeship bid.

Grenadier supporters have already circulated a letter among Northern Virginia delegates pledging them back the candidate of Alexandria Dels. Elise B. Heinz and Richard R. G. Hobson. The two delegates are supporting Grenadier. But Thomson, for his part, is said to be "pulling in chits" among legislators he has done favors for in the past.

One such Northern Virginia delegate who said Thomson helped him get apointed to influential committees and pay off a campaign debt plans to abstain if Thomson's name is placed in nomination in the House.

Under House Democratic caucus rules, Thomson's name automatically will be placed before the caucus because he has been certified as qualified by the House Courts of Justice Committee. This means it will not be necessary for one of his supporters to oppose the wishes of the Alexandria delegates publicly by nominating Thomson.

In the Senate caucus, however, Thomson must persuade one of the 34 Democrats to nominate him before he can be considered. Wilder, the Senate's only black member and a Thomson opponent, said Sen. Peter K babalas (D-Norfolk) has told him he will nominate Thomson.