RICHMOND, DEC. 8 -- Democrats in the Virginia Senate, repudiating their own majority leader and the state's segregationist past, chose a Norfolk legislator today over a more senior member to be the symbolic head of the General Assembly's upper chamber.

In a 15-to-14 vote behind closed doors, a coalition of urban blacks and rural legislators in the Senate's Democratic Caucus elected Sen. Stanley C. Walker of Norfolk as president pro tempore, a largely ceremonial job that nonetheless carries some authority in the tradition-bound Senate.

Walker was elected over Sen. Howard P. Anderson of Halifax, a Southside conservative who supported the state's program of Massive Resistance against desegregation in the late 1950s. Anderson's chief backer in today's election was Majority Leader Hunter B. Andrews of Hampton, who was joined by all seven Northern Virginia Democrats.

In addition to Anderson's defeat, Andrews also saw his increasingly tenuous hold over his fellow Democrats further loosened on two procedural votes, the defeat of a committee change he proposed and passage of a new party caucus rule he opposed.

"Hunter took it on the chin not once, not twice but three times today," said one conservative senator and Andrews ally.

While the votes had little to do with the Senate's day-to-day workings, they highlighted several senators' long-simmering resentment against Andrews, an extraordinarily powerful legislator who is considering running for governor in 1989.

After last month's legislative elections, Andrews rose to the top of the seniority list in the Senate, making him eligible to become president pro tempore. Although the post normally goes to the longest-serving member, Andrews declined the job, as did the next most senior Democrat. That left Anderson, 72, who has been in the Assembly since 1958, in line for the honorary presidency.

However, the candidacy of Anderson, who told The Washington Post in 1984 that he "would not change" his votes against integration if "the same conditions" of the 1950s existed years later, was unsettling to a number of Democratic senators.

Sen. Clive L. DuVal 2d (D-Fairfax), who was reelected caucus chairman today, said he and his Northern Virginia colleagues voted for Anderson because "the safest way and the best way was to observe seniority."

"Whatever the past history is, what Howard's done recently has been contrary to that," said DuVal, noting that Anderson has supported a black in his district for a judgeship and has voted with Northern Virginia on several issues.

Walker, 64, a businessman, ranks just behind Anderson in seniority and heads the Senate's Education and Health Committee.