HELENA, Mont. — In a coffee shop on Last Chance Gulch, a woman approached Mike Wheat to say she was planning to knock on doors for him. “It’s getting pretty brutal out there,” she said.

Mr. Wheat, a State Supreme Court justice running in the most expensive judicial race on record in Montana, nodded. In a parade of menacing television ads paid for by conservative groups, he has been attacked for “a history of supporting extreme partisan measures” (voting to raise fees on hunting licenses), and for allowing convicted criminals to use legal “loopholes” to go free. On the other side, unions and trial lawyers have accused his opponent, Lawrence VanDyke, of being “in the pocket” of out-of-state “special interests.”

When Justice Wheat, 66, decided to run for another eight-year term on the court, he said, “I never really anticipated that I would end up with a race like this. I never thought it would turn into this gigantic money battle.”

But judicial races have been evolving into another political battleground for big money. A last-minute surge of spending brought the total spent on television commercials to $12.1 million in 10 states, according to two groups that track judicial campaign spending. This election cycle, the spending race has been fueled by the Republican State Leadership Committee, which pledged to spend $5 million on a “judicial fairness initiative,” and contributed $400,000 in North Carolina last week.