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."

* * *

Montana has long prided itself on a refusal to be pigeonholed. It's the kind of place that votes Republican for president but elects Democrats to state office. Politicians wear bolo ties, tout their Montana credentials and use words like "hell" and "crap." People introduce themselves by saying what generation Montanan they are.

Consistently, the state fights against any mandate that smacks of Washington meddling, from the federal speed limit to the Citizens United ruling in early 2010, which opened the door to corporations and unions spending unlimited money on independent ads, echoing an earlier court ruling that equated money with free speech.

Before that, Montana had one of the country's toughest campaign finance laws, dating back 100 years, to the time of the copper kings. After one of those kings bribed state lawmakers to back him as senator, the state banned corporate political spending.

Even after Citizens United, the Montana Supreme Court insisted that Montana's legacy of corruption justified keeping the ban. In June, the U.S. Supreme Court squashed that move, saying the Citizens United decision applied to every state in the nation.

By then, dark money groups were already weighing in on Montana's Senate race.

The TV ads started in March 2011, the month after Rehberg announced. The Environmental Defense Action Fund attacked Rehberg for his stance on mercury emissions. The Electronic Payments Coalition praised Tester for his push to delay implementing new debit-card swipe fees.

"The thing that surprised me a little bit was how early they got involved," said David Parker, an associate professor of political science at Montana State University who tracked all 160 TV commercials as part of a book he is writing on the race. "And I think that was critical, because very early on, they were able to establish the contours of this race. The candidates were just busy putting their organizations together and raising money."

Most of the money spent in 2011 on TV ads came from groups that didn't have to report their donors. They also didn't have to report their ads to the Federal Election Commission, because they didn't specifically tell voters to vote for or against a candidate. Instead of saying "Vote for Rehberg," they said things like "Call Jon Tester. Tell him to stop supporting President Barack Obama." Ads like that only have to be reported to the FEC if they air during the two months before an election.

The only way to compile data on such ad spending is by visiting TV stations, which Parker did. ProPublica helped him collect information on the last round of ads.

Parker's data shows that several heavyweight conservative groups entered the fray in mid-2011 to try to cast Tester, whom they saw as vulnerable, as a big spender.

Crossroads GPS, the dark money group launched by GOP strategist Karl Rove, ran two ads in July 2011 similar to those attacking Democrats in other states for supporting excessive spending.

Also that month, a conservative group called Concerned Women for America Legislative Action Committee ran a sarcastic ad about a new miracle drug called "Spenditol," Washington's answer to America's problems. "Call Sen. Jon Tester," the ad said. "Tell him, stop spending it all." Similar ads ran against Democratic senators up for election in tight races in Florida, Nebraska and Ohio.

Several ads run by conservative groups backfired, messing up in ways that irked Montanans.

The National Republican Senatorial Committee — a party committee that reports its donors — ran an ad that appeared to show Tester with all five digits on his left hand. (Tester is well known for having lost three fingers in a childhood accident involving a meat grinder.) The U.S. Chamber of Commerce misspelled Tester's first name. A Montana cable operator yanked a Crossroads ad for claims the operator deemed false.

"The first one that burned me really bad was from the U.S. Chamber," said Verner Bertelsen, a former Republican state legislator and Montana secretary of state. "I thought — you buggers! We don't need you to come in here and tell us who to vote for."

Starting in July 2011, three new liberal dark money groups ran ads. Patriot Majority USA criticized Republicans for allegedly planning to cut Medicare and help to seniors. The Partnership to Protect Medicare praised Tester for opposing Medicare cuts.

And in October, weeks after forming, the dark money side of Montana Hunters and Anglers, Montana Hunters and Anglers Action!, launched its first TV ad, starring Land Tawney, the group's gap-toothed and camouflage-sporting president, who also served on the Sportsmen's Advisory Panel for Tester. At the time, the super PAC side of the group was basically dormant.

The new Hunters ad accused Rehberg of pushing a bill — House bill 1505 — that supposedly would give Washington politicians control of access to public lands in Montana. Rehberg, one of 60 cosponsors, argued the legislation was necessary to help the Department of Homeland Security protect the state from illegal immigrants, drug smugglers and terrorists.

"Nobody in Montana was talking about that bill," Greenwood said. "I've only heard it talked about in campaign ads. And it played a role throughout the election."

* * *

The gusher of outside money into Montana's Senate race was part of a larger pattern. Nationally, in addition to the $5.1 billion spent by candidates and parties, almost 700 outside spending groups dumped more than $1 billion into federal elections in the 2012 cycle, FEC filings show.

Of that, about $322 million was dark money, most of it from 153 social welfare nonprofits, groups that could spend money on politics as long as social welfare — not politics — was their primary purpose.

Relating those numbers to previous elections is a largely pointless exercise, akin to comparing statistics from baseball and lacrosse. The Citizens United ruling changed the game, opening the door to unlimited corporate donations to super PACs and to a new breed of more politically active nonprofits.

"Instead of being in a boxing match in a ring, you're in a dark alley being hit by four or five people, and you don't know who they are," said Michael Sargeant, the executive director of the Democratic Legislative Campaign Committee, which helps Democrats run for state offices.

Some of the players in the 2012 cycle were longtime activist organizations such as the liberal Sierra Club and the conservative National Right to Life Committee, with clear social welfare missions and only a limited amount of political spending. Other dark money groups were juggernauts like Crossroads GPS and Americans for Prosperity, founded years ago by conservative billionaire brothers Charles and David Koch, which crank up their fundraising during election years and devote more money to election ads than other nonprofits.

Finding out about some of the less prominent nonprofits was no easy feat. Many were formed out of post-office boxes or law firms. On their applications to the Internal Revenue Service, they minimized or even denied any political activity.

Documents for pop-up nonprofits like the conservative America Is Not Stupid and A Better America Now, both of which formed in 2011, led back to a Florida law firm that offered no explanations. The Citizens for Strength and Security Action Fund, a liberal pop-up group that spent millions on elections in 2010, closed down in 2011. In its place came a new group: the Citizens for Strength and Security Fund, which earlier this year bought almost $900,000 in ads attacking Rehberg and the Republican Senate candidate in New Mexico.

Groups picked names that seemed designed to confuse: Patriot Majority USA is liberal. Patriotic Veterans is conservative. Common Sense Issues backed conservatives. Common Sense Movement backed a Democrat.

As in the 2010 midterms, the dark money spent in 2012 had a partisan tilt. Conservative groups accounted for about 84 percent of the spending reported to the FEC — mainly through Crossroads GPS, Americans for Prosperity and the U.S. Chamber of Commerce. Liberal groups spent 12 percent of the dark money. Nonpartisan groups made up the rest.

Despite shelling out hundreds of millions of dollars, conservatives lost big. Only about 14 percent of conservative dark money went to support winners.

Still, campaign-finance reformers say it's a mistake to minimize the influence of this money.

"What these donors were buying was access and influence, not only to the candidates but to the party machine," said Paul S. Ryan, senior counsel for the Campaign Legal Center. "And they will get that access. On the Republican side, you have people lining up to kiss the ring of (billionaire donor) Sheldon Adelson. And on the Democratic side, you have even people critical of these groups meeting with the funders of these groups. This money is not going away."

Even though liberal groups spent far less than conservative ones, they had a higher success rate. About 70 percent backed winning candidates.

Some Democrats have shown distaste for the dark-money arts, pushing for more transparency. But liberal strategists are preparing to ramp up their efforts before the next election, unless the IRS, Congress or the courts change the rules.

"We probably have a lot less comfort with some of the existing rules that allow for the Koch brothers to write unlimited checks to these groups," said Navin Nayak, the senior vice president for campaigns at the League of Conservation Voters, a liberal social welfare nonprofit for more than 40 years. "But as long as these are the rules, we're certainly going do our best to make sure we're competitive and that our candidates have a shot at winning. We're certainly not going to cede the playing field to the Koch brothers."

* * *

By the time Tester and Rehberg started buying TV ads, outside groups had been defining the race for a year.

Rehberg, 57, a six-term congressman and rancher often pictured wearing a cowboy hat and a plaid shirt, was portrayed as voting five times to increase his pay and charging an SUV to taxpayers. Tester, 56, a farmer with a flat top, was dinged for voting with Obama 95 percent of the time.

Tester's campaign went up with ads in March, mainly to counter the outside messages.

"The original plans were going up 60 or 90 days later than that," Tester said. "But it was important...We had to remind people of who I am."

His early ads highlighted his Montana roots, depicting him riding a combine on his farm and packing up Montana beef to carry back to Washington.

Rehberg had less money, so his earliest TV ads, which mainly attacked Tester, went up in May.

Neither Rehberg nor anyone from his media staff responded to requests for an interview on his views on campaign finance. In the past, he has said he supports the Citizens United ruling.

Meanwhile, conservative groups bought TV ads that hit at Tester but stopped just short of telling people how to vote. For instance, the conservative 60 Plus Association spent almost $500,000 buying TV ads featuring crooner Pat Boone criticizing Tester over the health care law. None of that was reported to the FEC.

Over the summer, the Concerned Women for America's legislative committee, Crossroads GPS and the U.S. Chamber of Commerce all weighed in. The TV spots were overwhelmingly negative, and many of them were cookie-cutter ads, similar to those that ran in other states against Democrats.

Liberal groups bought TV ads, too, but that was only part of their game plan. They spent their dark money on retail politics, hitting the streets and knocking on doors.

In January, the League of Conservation Voters set up two offices in Montana — one in Missoula and one in Billings. It canvassed voters and hired a full-time organizer, reaching out to 28,000 sporadic voters to urge them to vote early by mail.

Lindsay Love, the spokeswoman at Planned Parenthood Advocates of Montana, another nonprofit that doesn't report its donors for election spending, said the group targeted 41,000 female voters. More than 1,500 people ended up knocking on 28,500 doors and making 162,000 phone calls, she said. The group sent out about 470,000 pieces of mail.

"It's hard to unpack this," Parker said. "But it's fascinating to look at groups like the League, unions and Planned Parenthood. By and large, they did phones, canvassing, mail, very little TV. One of the best ways to get out the vote is personalized contact."

Many liberal groups active in Montana, including Montana Hunters and Anglers, were connected through Hilltop Public Solutions, a Beltway consulting firm.

Barrett Kaiser, a former aide to Montana's other Democratic senator, Max Baucus, is a partner at Hilltop and runs its office in Billings. The Hilltop website notes that Kaiser helped with Tester's upset Senate win in 2006. Kaiser is also a good friend of Messina, the manager of Obama's 2012 campaign, who also once worked for Baucus.

Kaiser was on the board of the Montana Hunters and Anglers dark money group. Another Hilltop employee in Billings served as the treasurer for the Montana Hunters and Anglers super PAC.

Hilltop partners in Washington also helped run two other dark money groups that spent money on the Montana race: the Citizens for Strength and Security Fund and the Partnership to Protect Medicare.

The League of Conservation Voters and Planned Parenthood Advocates of Montana paid management fees to Hilltop.

No one from Hilltop returned calls, but Nayak and Love said they worked with Hilltop independently of other groups.

Outside groups are allowed to coordinate with each other or use the same consultants — they're just not allowed to coordinate with a candidate. By working together, groups can disguise who is actually behind an ad.

In early July, for instance, the League of Conservation Voters gave $410,000 to the Montana Hunters and Anglers super PAC — almost all the money the group raised as of that date.

When the super PAC spent the money on TV ads against Rehberg later that month, the spots were paid for by what appeared to be an organization of Montana hunters, not some Washington-based conservationist group. Nayak said that was not a coincidence.

"We figured having a local brand like that and partnering with them on local issues made more sense than having a D.C. brand," he said.

Nayak said the League did not donate money for the later ads pushing Cox, the libertarian.

It's not clear where that money came from. The dark money side of Montana Hunters and Anglers paid for the radio ads. The super PAC bought the TV ads and had to disclose its donors, but FEC filings show its money came mainly from two other super PACs, which in turn reported getting most of their money from unions and dark money groups, including the League.

* * *

As the Montana Senate race approached its climax, as many as five fliers landed in voters' mailboxes daily. Robocalls, supposedly illegal in Montana, interrupted meals. Strangers knocked on doors, promising free pizza for voting. People turned off their TVs, dumped their mail without looking at it and stopped answering the phone.

"My ex and I moved in together, because he had cancer and I took care of him," said Louise McMillin, 51, who lives in the university district in Missoula. "He kept getting polling calls as he was dying. After he died, I kept saying, 'He's dead, could you take his name off the list?' And they said, 'Sure, sure.' And they kept calling."

The race stayed tight. Demand for TV ad slots spiked, so the TV stations started raising their prices. The law required them to charge candidates their lowest rate. But outside groups? They could be hit up for whatever the market would bear.

Rehberg's campaign paid $400 to run a 30-second ad during the show Blue Bloods on Oct. 19 on the CBS affiliate in Great Falls. A week later, Crossroads GPS paid $2,000 for a slot during the same show.

Anything was fair game for the ads. One, from the super PAC Now Or Never, made fun of Tester's buzz cut, then showed his hair growing down to his shoulders, a bizarre sequence apparently designed to signal his ties to Obama. Another ad, from the dark money group America Is Not Stupid, featured a baby with a gravelly voice saying he didn't know what smelled worse, his diaper or Tester.

"By the middle of October, people were just so tuned out and quite frankly disgusted by all these third-party ads," said Ted Dick, the executive director of the Montana Democratic Party. "We found that face-to-face conversations toward the end were most persuasive and effective. That's the lesson we're taking forward."

There are other lessons. Tester said the Montana race made clear that candidates will have to raise money sooner, and go up with TV ads faster. Although uncomfortable with outside money, Tester also said it's just the way things are now, even on the liberal side.

"I mean, look, they did it," he said. "And with as many ads that were against me, I was glad they did. But it needs to be transparent. I mean, everybody's needs to be transparent... It's important to know who's spending money on who so you know why they're doing it. And the way the system is set up right now, there is no transparency. Very little."

Campaign finance reformers agree that knowing who is behind a message helps people assess it.

One example: Two postcards sent to thousands of Montanans just before the election didn't include the required notice saying who paid for them. One said Rehberg had wasted "hundreds of millions of our tax dollars on pork barrel projects," and urged people to vote for Cox, "a champion for fiscal responsibility." The other called Rehberg "the king of pork" and told people to vote for Cox.

Cox said he didn't send them. The bulk-mail permit on the postcards came back to a Las Vegas company called PDQ Printing, according to the U.S. Postal Service. In an online manual, PDQ describes itself as "Nevada's preeminent Union printer." No one there returned phone calls.

Greenwood, the head of the Montana Republican Party, filed a complaint with the FEC over the mailers. The complaint blames liberal groups and says they "engaged in a duplicitous strategy of supporting the libertarian candidate, Dan Cox, in a desperate attempt" to siphon votes from Rehberg.

More than likely, that complaint won't be resolved for years.

Greenwood said he didn't think disclosure was a cure-all. But he also said the current system marginalized political parties.

"Whether it's Montana Hunters and Anglers or (the conservative super PAC) American Crossroads, they are not responsive to the grassroots," Greenwood said. "These are the professionals and the money men who are not responsive at all to people. The system as it is now does not reflect what people want."

Besides picking between Tester and Rehberg, Montanans got a chance in this election to say how they want the system to work. On the ballot was an initiative — largely symbolic in light of recent court decisions — that declared that corporations are not human beings and banned corporate money in politics.

Gov. Schweitzer, a Democrat, and Bertelsen, the former Republican secretary of state, campaigned for the initiative. In a shocker for backers, almost 75 percent of voters supported it.

"I realized it absolutely didn't have any legal basis to do anything dramatic," said Bertelsen, who is 94. "But it's a case of saying, 'We don't like it.' I guess we could just sit down and not say a word. But the Supreme Court — I think they made a mistake. Money isn't speech, anyhow. It's just money."