SÃO PAULO, Brazil — The man many Brazilians thought would shake up October’s presidential election, Joaquim Barbosa, Brazil’s first black Supreme Court justice, announced on Tuesday that he would not run, upending the already unpredictable race.

Mr. Barbosa, 63, had joined the Brazilian Socialist Party in April, raising the prospect of a presidential bid. Even without declaring his candidacy, he was the choice of 10 percent of the respondents in a nationwide poll, thanks to his image as an anti-corruption crusader at a time when all of the major parties and many top politicians have been tainted by a wide-ranging bribery scandal.

But on Tuesday, in a message on Twitter, he said: “It’s decided. After many weeks of reflection, I have finally reached a conclusion. I do not intend to be a candidate for the president of the Republic. Decision strictly personal.”

“It changes the entire scenario,” said Monica de Bolle, a Brazil expert at the Peterson Institute for International Economics. “Polarization wins the day.”

Former President Luiz Inácio Lula da Silva, who last month began serving a 12-year prison sentence after a corruption conviction, is leading in the polls, but he is likely to be barred from running. Next in line is Jair Bolsonaro, a congressman and ultraconservative former army captain who was recently charged with inciting racism.

According pollsters, Mr. Barbosa might have been able to unite voters on the left and the right because of his socially progressive agenda and his high-profile battle against corrupt politicians from Mr. da Silva’s Workers’ Party during his years on the Supreme Court.

Mr. Barbosa, the eldest of eight children, worked as a janitor in a courtroom before going on to become the only black student in his law school class at the University of Brasília. In 2003, he was appointed to the Supreme Court, where he oversaw the trial of politicians implicated in a vote-buying scheme. When he retired in 2014 he was approached by a number of political parties.

This year’s presidential election will be the first since another corruption investigation, known as Lava Jato, or Car Wash, engulfed the country’s major political parties and landed Mr. da Silva in jail, convicted of receiving a luxury apartment as a bribe. Polls show that corruption is Brazilians’ No. 1 concern heading into elections.

Mr. Barbosa’s decision not to run is likely to fuel the already deep divisions in Brazilian politics, but it will also open up space for candidates trying to seize the middle ground, in particular Marina Silva, a former environment minister who left the Workers’ Party to create her own political movement.

“Marina Silva’s profile is very similar — they even talked about forming a ticket together, although it never happened,” said Kennedy Alencar, a political columnist for CBN Radio, referring to Ms. Silva and Mr. Barbosa. “They are both considered honest outsiders with a social commitment.”

Ms. Silva is the daughter of a rubber tapper and one of the few black Brazilians, along with Mr. Barbosa, to climb to the top of the country’s power structure. She has run unsuccessfully in two previous presidential elections, but this time her lack of ties to a major political party is an asset.

Anger at the political establishment has lifted the prospects of outsiders like Mr. Barbosa and Mr. Bolsonaro, who was long regarded as a fringe legislator, but who has gathered momentum with his promises to stamp out corruption, make it easier to own guns and give the police a freer hand to fight crime.

But there is another factor that could have a huge impact on what is becoming the most unpredictable election since the military dictatorship ended in the 1980s: Mr. da Silva.

After two terms, Mr. da Silva left office with an approval rating of 87 percent and even now, sitting behind bars, 30 percent of Brazilians say they would vote for him. His party insists that Mr. da Silva will be its candidate, but his candidacy is likely to be barred by the Supreme Electoral Court later this year. If he chooses to anoint a successor, his decision could tilt the race in his candidate’s favor, especially with Mr. Barbosa out of the race.

Political analysts say Ciro Gomes, the candidate of the leftist Democratic Workers Party, could eventually form an alliance with Mr. da Silva’s Workers’ Party, but so far he is trailing in the polls.

Juliete Araujo, a 24-year-old house cleaner from the impoverished northeast, said it was hard to trust politicians other than Mr. da Silva, who is widely known as Lula.

“Lula is the only one who has ever cared about us,” Ms. Araujo said. “Maybe I would have voted for Joaquim Barbosa, but now if Lula isn’t in the elections, I’ll just cast a blank ballot.”