The Virginia Senate, in a rare assault on the state judiciary, voted today to strip judges of lucrative retirement benefits that allow them to earn 3 1/2 years of retirement credits for every year they serve on the bench.

Minority Leader William A. Truban, in a major political coup for Republicans, pushed the hotly debated measure through the Senate on a narrow 21-to-19 vote over the violent objections of the Senate's usually powerful Democratic leadership.

"This is a justice to judges bill," said Sen. Charles J. Colgan (D-Prince William). "We should treat judges the same way we treat everyone else when they retire."

Most senators, including Truban, predicted the measure would be defeated by the House. "That bill is going to never-never land, the Bermuda Triangle of the Assembly," said Sen. Charles L. Waddell (D-Loudoun), who opposed the measure.

The lucrative judicial retirement benefits were instituted by the legislature more than a decade ago to attract qualified lawyers to the bench when judges' salaries were relatively low.

Truban and others argued that the $62,500-a-year salaries paid to most circuit court judges is incentive enough.

Other senators criticized the measure, saying that judicial pay is far below what a successful lawyer can earn.

"This is a good back-home bill," said Sen. Edward E. Willey (D-Richmond), influential chairman of the Senate Finance Committee. "But we have men of character on the bench. We have to have some fringe benefits to get judges of quality."

Sen. William E. Fears (D-Accomack) said he believes there is no shortage of applicants for judicial positions because of allegedly low salaries. "When you have a vacancy, the line forms around the block," he said. "Everybody wants that job."

"My concern is to make all state employes, regardless of position or influence, equal to the amount of retirement benefits for a year's service they receive," said Truban.

He noted that a 53-year-old lawyer who becomes a circuit court judge at the current salary of $62,500 can retire 12 years later with a retirement income of about $50,000, including Social Security payments and state retirement benefits.

A teacher earning $20,000 and retiring after 12 years would receive benefits totaling $3,722 a year, Truban said. A state employe with an average salary of $25,000 would get retirement benefits after 12 years of $4,712, he said.

Some legislators, who elect the state's 307 state judges, used the debate to lob attacks at the judiciary.

While urban jurisdictions may need higher salaries to attact members of the bar to the bench, Fears said, rural judges may be overcompensated for their workload.

"In rural areas, the judge is the richest lawyer in the courthouse," Fears said. "Many rural judges are the best golfers in the world; they're champions in all the country clubs."