By Anthony Boadle

BRASILIA (Reuters) - A ban on companies funding election campaigns in Brazil that was meant to clean up politics amid the worst graft scandal in decades is instead helping wealthy businessmen and candidates backed by evangelical churches to dominate major races at Sunday's city elections.

A Supreme Court campaign finance ruling last year was aimed at ending billions in big business largesse showered on politicians, after a probe into corruption at state oil company Petrobras sparked outrage at crony capitalism.

Yet in the run up to Sunday's municipal polls, the first since the ban, changes to campaign funding have not leveled the political playing field as intended.

"Ending corporate donations has, in fact, favored rich candidates who have their own resources," says Supreme Court Justice Gilmar Mendes, who heads Brazil's top electoral authority, the TSE.

Filling the funding gap left by the ban, wealthy candidates can and do donate up to 10 percent of their declared income to their own campaigns.

Nearly half the funding of Joao Doria, the millionaire businessman leading the race for mayor of Brazil's largest city, Sao Paulo, came from his own pocket, according to numbers from the TSE. He has given 2.94 million real ($914,000) to his campaign.

And while contributions from individual donors remain negligible overall, organized donation drives by churches and perhaps even crime gangs are influencing some specific races for mayors and town councilors across Brazil.

The ban on corporate donations has meant an end to very expensive campaigns that encouraged illegal funding practices.

"But even with less money going into campaigns, economic power is still a strong presence distorting the elections," said Nicolao Dino, Brazil's top prosecutor for electoral crimes.

PROSPEROUS POLITICIANS

Political kickbacks at Petrobras fueled popular anger at the winner of the 2014 presidential polls, Dilma Rousseff, who was dismissed from office by Congress last month on unrelated charges of breaking budget rules.

Sunday's elections are the first since Rousseff's removal and her opponents are expected to do well at the expense of her leftist Workers Party that was in power for 13 years.

During that time, investigators say the party received upward of 20 billion reais ($6.16 billion) in donations, mostly from corporations, many of them the big construction firms implicated in the Petrobras scandal.

Under the new system, rich candidates are declaring more taxable income than ever before, allowing them to donate larger amounts to their own campaigns.

The Estado de S.Paulo newspaper reported that 1 percent of the donors account for 25 percent of all contributions, and the largest of them are from businessmen.

In the southern city of Curitiba, the leading contender for mayor, Rafael Greca, paid 40 percent of his donations himself - totaling 600,000 reais.

Brazil's 2014 presidential campaign was more than 95 percent funded by corporate donations and personal donations to candidates have never been a big part of the political culture. But such contributions from members of the public will now play a greater role after the ban on corporate cash.

Brazil's rapidly growing evangelical churches, which are well funded by the tithes paid by millions of followers, are carving out an important part of the personal donation market

with preachers telling the faithful to donate to specific politicians, often ultra-conservatives.

In Sao Paulo, the No. 2 candidate Celso Russomanno is a lawmaker for the PRB, the party created by billionaire Brazilian evangelical preacher and media mogul Edir Macedo, a Datafolha poll showed.

Macedo's nephew, PRB Senator Marcelo Crivella, a bishop in his uncle's Universal Church of the Kingdom of God, is far ahead in the race for mayor of Rio Janeiro, the country's second city.

Brazil's Pentecostal Christian churches have greatly increased their clout in Congress and are pushing a conservative agenda that opposes abortion and gay marriage.

The churches cannot donate directly to candidates but their members can.

With candidates struggling to find funding for their campaigns, electoral and tax authorities say illegal contributions of undeclared money are on the rise, a traditional practice in Brazil knows as Caixa 2, or the parallel account.

DEAD DONORS

Authorities are worried that organized crime gangs, mainly drug traffickers, could step into the vacuum left by the absence of corporate funding.

"There could be illicit funding by criminal organizations, and we are particularly concerned with the elections in Rio de Janeiro, where you have drug traffickers, slum militias and illegal gambling," Mendes said.

A recent spate of murders of candidates in Rio de Janeiro points to organized crime trying to get its representatives elected, electoral prosecutor Dino said.

Electoral officials have discovered 108 dead people across the country who have been registered as contributing campaign funds and they suspect as many as 16,000 people on welfare programs making donations beyond their means that could come from others using their tax numbers.

Iagaro Jung Martins, Undersecretary of Tax Inspection, said Brazil has stepped up vigilance to detect fraud and candidates are held to drastic new rules on campaign spending that oblige them to report their accounts every 72 hours.

Sunday's elections are the first test of fundraising rules that might change Brazil's political culture.

"The parties will have to become more creative, go back to the streets, knock on doors and try to put individual campaign donations in the DNA of voters," said Lucas de Aragao, with consultancy Arko Advice.

(Reporting by Anthony Boadle; Editing by Brad Brooks and Alistair Bell)