RIO DE JANEIRO — President Dilma Rousseff emerged on Sunday as the front-runner in one of the most tightly contested presidential elections since democracy was re-established in Brazil in the 1980s, but she failed to win a majority of the vote, opening the way for a runoff with Aécio Neves, the pro-business scion of a powerful political family.

The strong showing by Mr. Neves, a senator from the state of Minas Gerais, enabled him to surpass Marina Silva, an environmental leader who soared in opinion polls in September, only to be eliminated from the race.

While Ms. Rousseff, 66, is expected to remain the favorite going into the Oct. 26 runoff, the surge by Mr. Neves reflects disenchantment among many voters with Ms. Rousseff’s leftist Workers Party, which is seeking to remain in power amid criticism over a sluggish economy and a scandal shaking the nation’s oil industry.

Despite a souring of the national mood during Ms. Rousseff’s tenure, including huge antigovernment street protests in 2013, her campaign was buoyed by policies that have focused on preserving jobs and expanding social welfare benefits.

Mr. Neves, a leader of the Brazilian Social Democracy Party, which put in place an economic stabilization program when it held power from 1995 to 2002, has criticized Ms. Rousseff for a scandal at Petrobras, the national oil company. The episode involved a former executive’s revealing a huge overbilling scheme intended to support political figures in Ms. Rousseff’s governing alliance.

But Ms. Rousseff’s emphasis on protecting gains in living standards, along with spending on attack ads, helped fortify her campaign over the past two months. Many voters expressed concern that rivals could disassemble the web of antipoverty programs begun by the Workers Party, and those worries eclipsed resentment over corruption.

“There’s a lot of corruption in the government, but there’s corruption in every government,” said Luís Carlos Silva, 47, a waiter at a restaurant in downtown Rio de Janeiro.

He emphasized that Ms. Rousseff’s party, which has been in power since 2003, had helped many poor Brazilians ascend to the middle class, especially in Ceará, his home state in northeast Brazil.

“Life has improved with Dilma,” Mr. Silva said, referring informally to the president by her first name, a common practice for politicians in Brazil.

The election has been followed closely throughout Latin America, with Ms. Rousseff’s government supporting leftist allies in Venezuela and Cuba. The campaigning has also fueled volatility in financial markets as big investors expressed anxiety over some of Ms. Rousseff’s policies, which have expanded the influence of big state companies in the economy.

Mr. Neves, 54, has signaled that he would put in place policies aimed at calming the markets, like easing controls on fuel prices and improving the transparency of public finances. A top adviser of his campaign is Armínio Fraga, a Princeton-trained former central bank president who now operates an investment firm based in Rio.

In an election full of twists, the campaigning was upended in August when Eduardo Campos, a candidate and former governor of Pernambuco, was killed in a plane crash. His running mate, Ms. Silva, a former environment minister who was born into poverty in the far reaches of the Amazon, took his place on the ticket and emerged as a leader in the race.

But missteps by Ms. Silva, like backtracking on support for same-sex marriage and offering vague descriptions of how she could reshape Brazil’s political institutions, sowed confusion among voters, and she lost ground as the election neared.

“Truthfully, none of the candidates are great,” said Lucio Claudio de Souza, 49, who runs a newsstand in Brasília.

Still, he said he believed that Mr. Neves would crack down on crime more effectively than other candidates, pointing to a proposal to lower the age at which minors can be tried as adults to 16.

“I think Aécio is the least worst,” he said.

Reflecting Brazil’s consolidation of democracy since military rule ended in 1985, voting in the elections unfolded largely without problems across the country, the Brazilian news media reported. Voters also chose governors and legislators in the election.

Mr. Neves’s Social Democracy Party bolstered its support in São Paulo, Brazil’s largest state, but lost ground to the Workers Party in his home state of Minas Gerais.

While Brazilian elections generally proceed without major claims of irregularities, fatigue and disenchantment among voters are also on the rise. For instance, a majority of the electorate wants an overhaul of legislation making it mandatory in Brazil for people between the ages of 18 to 70 to vote.

Ms. Silva tried to tap into that sentiment with a diffuse message of “new politics.”

“Of all the candidates, Marina is the only one who really represents a renovation,” said Carlos Alberto Ferreira, 62, a pensioner who works as a security guard at a parking lot to supplant his meager retirement income. “She talks directly to the people.”

Mr. Neves has to lure the support of voters like Mr. Ferreira if he is to mount a more serious challenge to Ms. Rousseff. But Mr. Neves’s party faces some skepticism from poorer voters and corruption problems of its own, including a bribery and price-fixing scandal over contracts to supply subway equipment in São Paulo.

The race between Ms. Rousseff, a former leftist guerrilla, and Mr. Neves, whose grandfather was elected president in 1985 but fell ill and died before he could take office, suggests that polarization could grow more acute. The two represent rival ideologies, with Ms. Rousseff hewing to state capitalism and Mr. Neves contending that the state’s role in the economy should be reduced.

Pointing to Ms. Silva’s new role as a potential kingmaker in the election, Fernando Henrique Cardoso, the former president and a supporter of Mr. Neves, starkly told reporters on Sunday what needs to happen now if their party is to unseat Ms. Rousseff.

“Marina needs to come over to our side,” he said.

Correction:

An article on Oct. 6 about the results of the Brazilian presidential election that forced the incumbent, Dilma Rousseff, into a runoff gave an outdated title for Eduardo Campos, a rival candidate who was killed in a plane crash in August. At the time of his death, he was a former governor of Pernambuco, not still holding office.

Mariana Simões contributed reporting from Rio de Janeiro, and Lucy Jordan from Brasília.

A version of this article appears in print on , on Page A4 of the New York edition with the headline: In Brazil’s Election, Incumbent Emerges as Front-Runner but Faces Runoff. Order Reprints | Today’s Paper | Subscribe