A former Illinois congressional candidate and a government watchdog organization have teamed up to sue the Internal Revenue Service, claiming the agency should bar dark money groups from funding political ads.

The lawsuit, filed on Tuesday by David Gill, his campaign committee and Citizens for Responsibility and Ethics in Washington, or CREW, is the first to challenge how the IRS regulates political spending by social welfare nonprofits, campaign-finance experts say.

As ProPublica has reported, these nonprofits, often called dark money groups because they don't have to identify their donors, have increasingly become major players in politics since the Supreme Court's Citizens United ruling in early 2010.

Gill, an emergency room doctor who has advocated for health-care reform, including a single-payer plan, was the Democratic candidate for the 13th district in Illinois last year. After a tight race, Gill ended up losing to the Republican candidate by 1,002 votes — a loss the lawsuit blames "largely, if not exclusively," on spending by the American Action Network, a social welfare nonprofit.

It's impossible to say for certain why Gill lost. He had lost three earlier races for a congressional seat.

But the American Action Network, launched in 2010 by former Minnesota Republican Sen. Norm Coleman, played a role. It reported spending almost $1.5 million on three TV commercials and Internet ads opposing Gill, mainly in the weeks right before the election. That was more than any other outside group spent on the race, and more than Gill's principal campaign committee spent on the entire election, according to Federal Election Commission records.

Though Gill had never held public office, the American Action Network ads described him as "a mad scientist" who supported sending jobs to China, channeling money to the failed green-energy company Solyndra, and making a mess out of health care and Medicare.

Gill said he ran into people every day who said they weren't voting for him because of claims he would destroy Medicare.

"I think that certainly the money put forward — they saw that they could have an impact here," Gill said of the American Action Network. "They wanted to put their money where it could make a difference between victory and defeat."

Dan Conston, spokesman for the American Action Network, described CREW as a "left-wing front group" in an email. He said Gill was a "failed candidate with an extreme ideology, looking to blame anyone but himself for losing his fourth-straight congressional election."

Nonprofits like the American Action Network have poured hundreds of millions of dollars into political ads in the last two election cycles. Like super PACs, these groups can accept unlimited donations. But super PACs must identify their donors, allowing voters to see who is behind their messages.

The Gill lawsuit, filed in U.S. District Court in the District of Columbia, alleges the IRS failed to properly regulate the American Action Network, citing seemingly contradictory definitions the agency has applied to such groups for years.

The statute governing social welfare nonprofits says they should be operated "exclusively" for promoting social welfare. But the IRS paved the way for political spending by these groups by interpreting "exclusively" as meaning the groups had to only be "primarily" engaged in promoting the public good. Some groups have taken this to mean they can spend up to 49 percent of their money on election ads.

The lawsuit claims the IRS' interpretation of the law "is arbitrary, capricious, and contrary to law," and asks for an injunction prohibiting the agency from using it.

Melanie Sloan, CREW's executive director, blamed the IRS for sitting on its hands as social welfare nonprofits have been formed specifically to run negative ads paid for by anonymous donors.

"Now the IRS can explain its deplorable inaction in federal court," she said.

The IRS didn't respond to requests for comment Tuesday. It typically doesn't comment on issues related to individual taxpayers.

The American Action Network has been one of the more controversial dark money groups active in politics. Conston said the American Action Network's primary focus was on non-electoral activities and called the dispute over the group's election spending a "tired long-since settled argument."

In filings to the IRS, the group said it spent $25.7 million in its 2010 tax year. In separate filings to the Federal Election Commission, it reported spending about $19.4 million over the same period on political ads, or about 76 percent of the total expenditures reported to the IRS.

If the group stays on its current schedule, American Action Network won't file its taxes covering the 2012 election until May 2014.