WASHINGTON (AP) — A series of nonprofit groups backed by secret donors spent millions of dollars to help elect North Carolina Sen. Thom Tillis in last year's midterm elections, paying for television ads and crucial voter outreach efforts in what ended up as the most expensive Senate race in U.S. history.

Tax filings made public on Tuesday show how some of those nonprofits were working together. In all, about 30 nonprofits played a role in the election, with the majority spending money to help Republican Tillis beat incumbent Democrat Sen. Kay Hagan. The total cost, between the candidates and the outside groups, came to about $118 million, according to the Center for Responsive Politics, a Washington-based political tracker.

Nonprofit groups can accept donations of any size and are not required to disclose who is giving them money. In exchange for those privileges, they are supposed have "social welfare" as their primary mission and limit their overtly political activity. Some of the best-known social-welfare nonprofits are AARP and the National Rifle Association.

Political campaigns, by comparison, must abide by contribution limits and disclose their donors. The political groups known as super PACs can accept donations of any size but also must disclose the names of donors.

Some of the nonprofit groups involved in the North Carolina race appear to have pushed the limits of what is allowed by law.

Perhaps the starkest example is Carolina Rising, a nonprofit formed in the spring of the election year by Dallas Woodhouse, who is now executive director of the state's Republican Party. Tax filings show his group spent $4.7 million on Tillis-boosting ads, nearly every penny of its budget.

Woodhouse seemed to wipe away any veneer that his group had a "social welfare" mission when he talked to a television reporter at an election night party.

On live TV, the reporter said to Woodhouse, "You just mentioned you spent a whole lot of money to get (Tillis) elected, right?" Woodhouse replied, "$4.7 million. We did it."

The political watchdog group Citizens for Responsibility and Ethics in Washington had complained to the Internal Revenue Service that Carolina Rising abused its nonprofit status.

In an interview with The Associated Press on Tuesday, Woodhouse said Carolina Rising's activities were "100 percent within the law."

Tax documents made public on Tuesday show that Carolina Rising received almost all its money from another nonprofit, Crossroads GPS. Nonprofits must publicly disclose when they give money to other nonprofits.

Crossroads was co-founded by Karl Rove, a strategist for former President George W. Bush. Ian Prior, a spokesman for Crossroads, said Tuesday in a statement that he is "confident based on our written agreements with each one of those nonprofit organizations that our grants were used for the nonpolitical purposes that they were given."

While the new tax documents show that Crossroads gave the money to Carolina Rising, they do not reveal who gave the money to Crossroads.

Bob Hall, a campaign finance reform advocate with Democracy North Carolina, said the practice of anonymous donors hiding behind nonprofit groups to back candidates "all smells terrible."

"That's the system that we have come to," Hall said, "where the superwealthy and large corporations can believe that they can buy positions in Congress and statehouses."

Publicly available tax filings show only the size of a nonprofit's largest contributions, with the names of the donors redacted. Roughly 90 percent of Crossroads' $69 million budget for 2014 came from 19 donations of $500,000 or more. The largest two checks were for $20.6 million and $14.5 million, the tax documents show.

Those 19 people helped Tillis in at least four different ways, the new tax documents suggest.

In addition to the money it gave Carolina Rising, Crossroads also gave millions to the U.S. Chamber of Commerce and the American Future Fund, which, in turn, spent money on efforts to boost Tillis.

Then, about a month before the election, Crossroads GPS put $5 million of its money directly into an advertising campaign to back Tillis.

"Thom Tillis," a narrator in one of the ads says, as a message to "Vote Thom Tillis for U.S. Senate" appears on screen. "North Carolina values for a change."

___

Robertson reported from Raleigh, North Carolina.

___

On Twitter follow Julie Bykowicz at http://twitter.com/bykowicz and Gary D. Robertson at http://twitter.com/garydrobertson

___

This story has been corrected to show Tillis' first name is Thom, not Tom.