Under President Dilma Rousseff, Brazil has transformed from one of the world's brightest economic successes to a nation of stagnation, with growing inflation and a weakening currency. Business leaders are spooked at the prospect of Rousseff returning for a second term and her administration's fading popularity made international headlines earlier this year as millions of Brazilians protested the country's perceived mismanagement of the World Cup games. And yet, with only a few days left before Brazil's presidential election, Rousseff is enjoying a surge in the polls against rival Marina Silva and is all but expected to easily advance into a runoff contest later this month.

Rousseff's rebounding approval ratings suggest Brazil isn't quite ready to say goodbye to its venerable Workers' Party after 12 years of rule or the legacy of its beloved founder, Luiz Inácio Lula da Silva. Under his presidency from 2003 to 2011, Brazil became one of the world's largest economies and was one of the few nations to thrive during the 2009 global recession. Quality of life soared as almost 40 million Brazilians moved up to the middle class under Lula's welfare programs.

Rousseff's presidency has yielded less stellar results. Brazil's once vibrant economy has contracted for two consecutive quarters, annual inflation has exceeded the official target of 4.5 percent for more than two years, and the Brazilian real dropped to its weakest point in six years on Friday. Business leaders blame the technical recession on heavy taxes, sluggish investment, outdated infrastructure and government inefficiencies. China's and Argentina's economic woes -- both nations are significant trade partners -- have also hurt Brazil.

"There is quite a lot of frustration in the population with things like corruption and these big building programs for the World Cup, combined with what they see as very poor public health services and infrastructure," said Melvyn Levitsky, a professor of international policy at the University of Michigan who served as the U.S. ambassador to Brazil under President Bill Clinton. "The question is, are they going to see Marina Silva as someone who can do a better job than Dilma?"

For months, it appeared voters would punish Rousseff for the economic slowdown. In late August, Silva, the anti-establishment candidate, was projected to win 50 percent of the vote, compared with Rousseff's 40 percent share, according to a Datafolha poll. But earlier this week, another Datafolha survey suggested Rousseff would gain 49 percent of the electorate against Silva's 41 percent in the expected second-round vote. A poll conducted by media giant Globo Comunicações also put Rousseff at the front of the pack this week, after predicting Rousseff and Silva were tied at 41 percent only last week.

"You have to put yourself in the shoes of the population that used to be poor 20 years ago. There have been huge changes with regards to their improvements in terms of salary and access to credit and in equality and available jobs. So these people are afraid of somehow of losing those benefits," Carlos Pereira, a political analyst at the Getulio Vargas Foundation think tank in São Paulo, said. "So, on the one hand, you have a very bad economic management, but, on the other, you have social benefits, social inclusion and better conditions of life."

Low unemployment has also helped manage voters' disappointment with Rousseff's leadership, Levitsky said. "If they see prices really going up and their wages are going down or staying the same, then that would be a big deal. But in terms of feeling it in their pocketbook, I think they are still feeling like they are doing OK," he said.

Rousseff has vowed to turn the economy around with tax cuts, social spending and more access to credit, while Silva has advocated for sustainable development and a more transparent government. The election on Sunday likely won't decide a winner. Brazil requires candidates to win an outright majority of voters get to choose again between the two top vote-getters in a runoff election. Voting is mandatory. Ten other less popular candidates are also vying for the presidency.

Silva leaped into the race in August after the Brazilian Socialist Party's preferred candidate, former governor Eduardo Campos, died in a plane crash. If she wins, she would become the nation's first black president, no small matter in a country where more than half of the population self-identifies as of African descent, according to the Brazilian Institute of Geography and Statistics.

Silva's personal story is also compelling -- she taught herself to read and write as a teenager and is an evangelical Christian. But her limited governing experience and vague campaign promises have hurt her, as have Rousseff's aggressive ad attacks that describe Silva as fickle and unreliable. Silva left the Workers' Party in 2009 after quitting as environment minister.

"In the beginning, Marina was ready to capture that discontented voter, but, however, she is fading away with what’s going on right now," Pereira said. "Dilma has had a very effective negative campaign."

The runoff election could further transform the dynamics of the campaign. Candidates will be given the opportunity to address voters with 10 minutes of TV time every night. So far, Rousseff has had the advantage with a robust marketing campaign, as well as other perks of incumbency.

With voters turning away from Silva, it's becoming increasingly more possible that the election could end in an upset and see Aécio Neves of the Brazilian Social Democratic Party make the runoff. He's the most conservative candidate of the three, a senator and the grandson of a former president. A Datafolha poll late Thursday showed Silva and Neves in a statistical tie for second place. Some have predicted he will endorse Silva at the last minute to help defeat Rousseff, but that would come after months of him describing her as unprepared for the presidency. 

Neves' endorsement, however, still might not be enough to overcome the widespread influence of Brazil's Workers' Party. Lula's overwhelming electoral victory in 2002 was the first time Brazilians across nearly every social swath backed a working-class leader. Democratic stability under his presidency helped counter decades of economic uncertainty and saw the creation of an estimated 17 million jobs, as well as a generous social welfare program benefiting 1 in 4 Brazilians. Rousseff worked as Lula's chief of staff and he tapped her as his preferred successor during the 2010 election.

"Rousseff won because Lula was shining on her," Levitsky said. "He still helps her a lot ... He is just a beloved figure, particularly among the lower classes and the middle classes. If they come out to vote, they are going to go basically for his person."