In the waning days of Montana's hotly contested Senate race, a small outfit called Montana Hunters and Anglers, launched by liberal activists, tried something drastic.It didn't buy ads supporting the incumbent Democrat, Sen. Jon Tester. Instead, it put up radio and TV commercials that urged voters to choose the third-party candidate, libertarian DanCox, describing Cox as the "real conservative" or the "true conservative."

Where did the group's money come from? Nobody knows.

The pro-Cox ads were part of a national pattern in which groups that did not disclose their donors, including social welfare nonprofits and trade associations, played a larger role than ever before in trying to sway U.S. elections. Throughout the 2012 election, ProPublica has focused on the growing importance of this so-called dark money in national and local races.

Such spending played a greater role in the Montana Senate race than almost any other. With control of the U.S. Senate potentially at stake, candidates, parties and independent groups spent more than $51 million on this contest, all to win over fewer than 500,000 voters. That's twice as much as was spent when Tester was elected in 2006.

Almost one quarter of that was dark money, donated secretly to nonprofits.

"It just seems so out of place here," said Democrat Brian Schweitzer, the governor of Montana who leaves office at the end of this year. "About one hundred dollars spent for every person who cast a vote. Pretty spectacular, huh? And most of it, we don't have any idea where it came from. Day after the election, they closed up shop and disappeared into the dark."

Political insiders say the Montana Senate race provided a particularly telling glimpse at how campaigns are run in the no-holds-barred climate created by the Supreme Court's 2010 Citizens United decision, giving a real-world counterpoint to the court's assertion that voters could learn all they needed to know about campaign funding from disclosure.

In many ways, Montana was a microcosm of how outside spending worked nationally, but it also points to the future. Candidates will be forced to start raising money earlier to compete in an arms race with outside groups. Voters will be bombarded with TV ads, mailers and phone calls. And then on Election Day, they will be largely left in the dark, unable to determine who's behind which message.

All told, 64 outside groups poured $21 million into the Montana Senate election, almost as much as the candidates. Party committees spent another $8.9 million on the race.

The groups started spending money a year before either candidate put up a TV ad, defining the issues and marginalizing the role of political parties. In a state where ads were cheap, they took to the airwaves. More TV commercials ran in the Montana race between June and the election than in any other Senate contest nationwide.

The Montana Senate race also shows how liberal groups have learned to play the outside money game — despite griping by Democratic officials about the influence of such organizations.

Liberal outside groups spent $10.2 million on the race, almost as much as conservatives. Conservatives spent almost twice as much from anonymous donors, but the $4.2 million in dark money that liberal groups pumped into Montana significantly outstripped the left's spending in many other races nationwide.

As in other key states, conservative groups devoted the bulk of their money in Montana to TV and radio ads. But sometimes the ads came across as generic and missed their mark.

Liberal groups set up field offices, knocked on doors, featured "Montana" in their names or put horses in their TV ads. Many of them, including Montana Hunters and Anglers, were tied to a consultancy firm where a good friend of Jim Messina, President Barack Obama's campaign manager, is a partner.

The end result? Tester beat Republican Rep. Denny Rehberg by a narrow margin. And the libertarian Cox, who had so little money he didn't even have to report to federal election authorities, picked up more votes than any other libertarian in a competitive race on the Montana ballot.

Montana Republicans blamed Montana Hunters and Anglers, made up of a super PAC and a sister dark money nonprofit, for tipping the race. Even though super PACs have to report their donors, the Montana Hunters and Anglers super PAC functioned almost like a dark money group. Records show its major donors included an environmentalist group that didn't report its donors and two super PACs that in turn raised the bulk of their money from the environmentalist group, other dark money groups and unions.

"Part of what's frustrating to me is I look at Montana Hunters and Anglers and say, 'That is not fair,'" said Bowen Greenwood, executive director for the Montana Republican Party. "I am a hunter. I know plenty of hunters. And Montana hunters don't have their positions. It would be fairer if it was called Montana Environmental Activists. That would change the effect of their ads."

Cox and Tester deny the group's efforts swung the race. No one from Montana Hunters and Anglers returned calls for comment.

Tester, who's argued that all groups spending on elections should disclose their donors and also pushed against super PACs, said he wasn't familiar with any of the outside groups running ads. By law, candidates are not allowed to coordinate with outside spending groups, which are supposed to be independent.

Despite his ambivalence, he said he was glad the outside groups jumped in.

"If we wouldn't have had folks come in on our side, it would have been much tougher to keep a message out there," Tester said. "We had no control over what they were saying. But by the same token, I think probably in the end if you look at it, they were helpful."