Brazil’s jailed former president, Luiz Inácio Lula da Silva, has abandoned his long-running prison-cell campaign to reclaim leadership of his country, bringing a scintilla of certainty to the most tempestuous and unpredictable Brazilian election in decades.

Lula has towered over this year’s profoundly polarized race to become the next president of Latin America’s largest democracy despite having spent much of the year behind bars in southern Brazil serving a 12-year sentence for corruption.

The former president retains widespread support, but was officially barred from running by Brazil’s top electoral court at the start of this month.

Until this week, Lula and the leftist Workers party (PT) he helped found in 1980 had continued to publicly insist he would stand, in what experts described as a two-pronged strategy designed to propel another PT politician into power and guarantee the former president a pardon once that happened.

Polls gave Lula, who left power in 2011 before Brazil was plunged into its worst recession in modern history, a sizeable lead over the other frontrunner, the homophobic far-right candidate Jair Bolsonaro, who was stabbed at a campaign event last Friday.

However, on Tuesday afternoon the PT finally abandoned the political charade that Lula would be able to stand, announcing that the party’s vice-presidential candidate, Fernando Haddad, would instead step up.

Speaking outside the federal police headquarters in Curitiba where Lula has been held since April, the PT president, Gleisi Hoffmann, said Lula had asked for that decision be taken “so as not leave Brazil and the Brazilian people without an alternative”.

“We always believed Lula’s candidacy was essential to take Brazil out of the crisis and that is why we fought so hard for him,” Hoffmann told a crowd of supporters. “But unfortunately … Lula’s rights were not respected … This is a moment of pain, indignation and anger for the PT … but indignation, pain and revolt have always been part of our trajectory.”

In an open letter “to the Brazilian people” that was read to the gathering Lula denounced his imprisonment as a “judicial farce” and “political revenge” but said it was time to pass on the baton to “comrade Fernando Haddad”.

“Fernando Haddad … will be my representative in this battle … If they think they can silence our voice and defeat our project for this country they are very mistaken,” Lula said. “Our name is now Haddad!” he added, to applause and chants of “Free Lula!”

“From here on Fernando Haddad will be Lula for millions of Brazilians.”

Haddad, a 55-year-old former philosophy lecturer and education minister who was mayor of São Paulo from 2013 to 2017, told the rally he felt the pain of millions of Brazilians who would no longer be able to vote Lula.

“It is a pain felt by the country’s poorest people ... people who did not have access to even a plate of food [before Lula came to power].” “Lula – our Lula, our friend, our dear Lula – represented and continues to represent a watershed in Brazilian history,” he said.

But Haddad said he would accept the mission handed to him by Lula to “bring back the good times” and “hand Brazil back to the Brazilians”. “It is a monumental task that we have before us,” he said before concluding: “Viva Democracy! Free Lula! And Long live the Brazilian people.” The crowd responded with cries of “Haddad, presidente!”

Lula’s announcement was trailed by a PT public relations blitz which included videos urging Lula supporters to “make Brazil happy again” by backing his proxy on 7 October.

Tuesday’s long-anticipated move comes just 26 days before 147 million Brazilian voters head to the polls. That leaves Lula and the PT the tiniest of windows in which to transfer his considerable support to Haddad, a bookish politician who remains relatively unknown outside south-eastern Brazil and is not famed for his charisma.

José Roberto de Toledo, a political journalist from the magazine Piauí, said surveys suggested there was still time. “Haddad has gone from 2% [in June] to four, from four to six, from six to nine. He’s growing very fast.”

Toledo, who is renowned for his ability to decipher election polls, predicted Lula’s surrogate would need about 18% to make it into a second round runoff against Bolsonaro who currently boasted about 24% of intended votes but had effectively been forced out of the campaign by his stabbing. “I think he’ll get there.”

Maurício Santoro, a political scientist at Rio de Janeiro’s state university, said: “I would say … the second round is shaping up to be between Bolsonaro and a leftist.”

One possibility is Ciro Gomes, a silver-tongued 60-year-old from the Democratic Labour party (PDT) who is rising in the polls and – like Lula – hails from Brazil’s north-east, the region with the second-largest number of voters.

“[My] message is finding its way into people’s hearts,” Gomes, who has made two previous bids for the presidency and whose campaign Lula has tried to thwart, told reporters on Tuesday.

But Santoro said his money was on Haddad: “[Then] it will be Bolsonaro versus the PT and Brazil will catch fire in the second round.”