By John Lyons 

PAULISTANA, Brazil--Like most people in this parched corner of Brazil's impoverished northeast, Bartholomew Francisco wants President Dilma Rousseff to win re-election in this nation's close presidential race on Sunday.

His reason: gratitude for welfare money that is getting his family through a yearslong drought that has killed his crops and starved his cows. More than half of his hard-bitten, northeastern state of Piauí gets such aid and 70% of voters here backed Ms. Rousseff in a first round vote Oct. 5.

Meantime, 1,400 miles to the south in São Paulo, disdain for the 66-year-old incumbent is running high, raising the fortunes of her conservative challenger Aécio Neves. At the World Cup opening game there in June, thousands of mostly better-off Brazilians shouted out a vulgar anti-Rousseff chant every time she appeared on the jumbo screen.

In a tight election playing out against a fading commodity boom, Brazilian voters are deeply split between regional haves and have-nots. Poor and rural voters, lifted by federal aid during 12 years of Workers' Party governments, mainly back Ms. Rousseff.

Wealthier voters, concentrated in cities, tend to blame Ms. Rousseff for undermining the economy with interventionist policies and allowing corruption to flourish, and back Mr. Neves as a candidate of change.

"What we have now is more than polarization, it is a schism, and very nearly class conflict," said Mauro Paulinho, the director of Brazil's Datafolha polling firm.

The race is among Brazil's closest since returning to democracy in 1985. A poll published on Monday by Datafolha has Ms. Rousseff leading with 46% to Mr. Neves's 43%--a result within the margin of error.

Much is at stake for a resource-rich economy hit by falling prices for iron ore and other commodities. Brazil raced to 7.5% growth in 2010, but is now battling the twin evils of economic stagnation and rising inflation. Since Ms. Rousseff took office in January 2010, Brazil's stock market has fallen by more than 20% and its currency has lost a third of its value against the dollar. Investors are pessimistic Brazil's business climate could worsen if Ms. Roussef wins, and markets have fallen each time she improves in the polls.

Economic decline is exposing age-old social and economic divides in a country that has long struggled with one of the widest rich-poor income gaps in the world. The rift is likely to complicate the political landscape for whoever wins, adding obstacles for a nation searching for a formula to restore its growth path.

For many better-off voters, the biggest thing going for Mr. Neves right now is that he isn't Ms. Rousseff. All but written off a few weeks ago, he surged past another challenger, environmentalist Marina Silva, to finish in second place behind Ms. Rousseff in the Oct. 5 first-round vote, setting up Sunday's runoff. Change-minded voters had supported Ms. Silva, but switched en masse to Mr. Neves after Ms. Silva withered under a barrage of negative ads.

Mr. Neves, a 54-year-old scion of a political dynasty in Brazil's more-developed south, is trying to reach down the economic ladder as far as he can. He is promising to maintain the popular federal welfare programs, but he is also running as a better economic manager. In speeches and debates, he vows to fight inflation, which is hovering around 6.75%, cutting deeply into working families' budgets.

"Tell me, does your money buy the same things it does today as it did four years ago?" he asked the audience during a recent televised debate against Ms. Rousseff.

His target is people like Luiz Carlos Coutinho, a 47-year-old delivery van driver from the rough outskirts of São Paulo. He earns too much to receive welfare. The public services he does use, such as hospitals and schools, are dismal. "It's time for change," said Mr. Coutinho, who voted for Ms. Rousseff in 2010 but now backs Mr. Neves.

Mr. Neves criticizes what he says is Ms. Rousseff's heavy hand in the economy, leading to inefficiency and corruption. He is also vowing to overhaul institutions such as state-run oil firm Petroleo Brasileiro SA, which is under Federal Police investigation for alleged embezzlement schemes.

Ms. Rousseff, a onetime Marxist guerrilla turned politician, says the investigation itself shows she is tough on corruption. She says her economic policies have lifted Brazil's underclass and have kept unemployment rates low even during global turbulence.

And she is hitting back, accusing Mr. Neves of being an antipoor elite who would reverse her government's philosophy, using state companies and banks to create jobs, while funding large-scale poverty eradication programs to lift the poor. "We can't go back to the days when Brazil was governed by the elites for the elites," Ms. Rousseff says in a television ad.

In 2013, Ms. Rousseff's predecessor Luiz Inácio Lula da Silva, founder of the Workers' Party, began a landmark poverty-eradication program now credited with lifting 36 million Brazilians from extreme poverty. The flagship program, Bolsa Familia, pays 14 million families a monthly stipend to keep their children in school.

Just days before the campaigns started, Ms. Rousseff raised Bolsa Familia payments by 10%.

It is a potent argument in Brazil. Some 60 million voters, or 42% of Brazil's electorate, live in households earning less than $590 a month, the lowest income demographic tracked by the Datafolha polling firm. Ms. Rousseff has the support of 53% of this group, compared with 35% for Mr. Neves.

It is enough that Ms. Rousseff potentially can trail Mr. Neves in all higher income brackets and still win, political analysts say.

The political legacy of the program is visible in Ms. Rousseff's deep support in the drought-stricken northeast, a nine-state region of coastal slums and arid backlands that accounts for more than half of Bolsa Famila spending.

"This is the first government to pay any attention to us, and before they did we could really go hungry out here," said Mr. Francisco, a wiry 47-year-old Rousseff backer who lives with his small family on a dusty plot outside the town of Paulistana in Piauí state.

Illiterate himself, he sent his son to school thanks to Bolsa Familia payments. After a daughter was born blind and mute, he started getting a full minimum wage a month under a program for poor families with disabled children. He lived the first 35 years of his life without electricity. Now his home is connected to the grid under a program called "Light for All."

In the final days before the election, Ms. Rousseff is also courting votes among families who left poverty thanks to Workers' Party programs. In one television ad, a rural family in a pickup truck passes a version of itself from 12 years ago trudging on foot. The message: They would slide back if they don't vote for Ms. Rousseff on Sunday.

Loretta Chao contributed to this article.