Brazil's former president, Luiz Inácio Lula da Silva, was surrounded by supporters as he campaigned for the reelection of Sao Paulo's mayor, Fernando Haddad, in late September. (Andre Penner/AP)

As samba drums beat a machine-gun rhythm, a few thousand people in a Rio square began singing an old campaign song for the man once hailed as the most beloved Brazilian politician in a generation.

“Lula-lá, a star shines, Lula-lá, hope grows,” the supporters sang at the nighttime rally last month in a drab outlying city neighborhood.

Luiz Inácio Lula da Silva, known as Lula, is a giant in modern Latin American politics. In eight years as president, he presided over an extraordinary economic boom while introducing welfare policies that helped lift 36 million people out of poverty. In 2009, President Obama called him “the most popular politician on Earth.”

Speaking at the recent rally, the gray-haired, 70-year-old Lula demonstrated his trademark charisma, drawing laughs and cheers as he reminded his audience of his successes.

“We showed that when the poor are included in the economy, the country grows,” he said, in a voice so gravelly it could pave a road.

But these days, Brazil’s leftist icon has been shorn of much of his political force.

Lula has been charged with corruption and money-laundering offenses in a multibillion-
dollar graft scheme
at state-run oil giant Petrobras that has led to the indictments of hundreds of people — including former officials from his Workers’ Party. He faces similar charges in a separate investigation involving a construction giant also embroiled in the Petrobras probe.

Brazil’s economy has sunk into recession. Lula’s hand-picked successor as president, Dilma Rousseff, was impeached in August for breaking budget laws. High-profile political candidates for whom Lula campaigned in municipal elections this month lost — including one of his sons — and his Workers’ Party won less than half the city halls it conquered four years ago.

“Economy and corruption. These two things together were a very powerful cocktail that defeated this popularity that Lula had,” said Mauricio Santoro, a professor of international relations at Rio’s State University.

Yet Lula is far from finished as a politician. Recent polls even showed him as a front-runner for the 2018 presidential election, with as much as one-third of the vote, although they indicated he would tie or narrowly lose in most scenarios in a second runoff round.

“He is the guy who most helped the country,” said Thiago Oliveira, 32, a dance teacher attending the recent campaign rally for a leftist candidate in the blue-collar neighborhood of Bangu.

During Lula’s two terms, from 2003 through 2010, Brazil’s economy flourished thanks to a global commodity boom and a surge in consumer spending. Millions of low-income families benefited from a novel welfare program that provided cash payments as long as parents ensured their children went to school and got medical care.

Even during those years, said Santoro, the political scientist, there were signs that things could go wrong.

“The seeds of the problem were already there,” he said. “The issue of corruption, and his decision to make Dilma [Rousseff], a difficult person, his heir.”

In 2005, Lula’s first government was rocked by a scandal called the Mensalão, or ‘big monthly payment,’ in which lawmakers from other parties were paid to vote for government measures.

With Brazil’s economy expanding, Lula was reelected a year later — but the controversy dented the reputation of the Workers’ Party, which had presented itself as a clean alternative to Brazil’s “old politics.”

“This was the way Brazil was always governed. But for the left to have adopted these methods was a brutal mistake,” said Tarso Genro, who held three ministerial posts under Lula and served as Workers’ Party president.

Under Rousseff, government spending surged and the commodities boom ended. Her heavy-handed policy interventions, such as forcing utilities to cut electricity prices, eroded investor confidence. Politically, she was seen as authoritarian and inflexible. Some leftist Brazilians blame her for the harm done to Lula’s legacy.

“Dilma damaged much of what he did,” said Sharllene Carmo, 27, who attended the recent rally.

Prosecutors have painted a far darker picture of Lula, however, alleging that he had a huge role in the Petrobras corruption scandal. They say he was the mastermind of an illegal scheme involving $26 million in kickbacks, payments and campaign donations, part of which was aimed at keeping his Workers’ Party in power.

Yet just weeks after prosecutors aired those allegations in a nationally televised news conference, a poll found that 34 percent of Brazilians would still vote for Lula in the 2018 elections. In addition, 43 percent said they liked him, while only 36 percent didn’t. The rest had no opinion.

Renato Meirelles, president of Sao Paulo’s Locomotiva research institute, which examines trends and opinion among Brazil’s lower classes, acknowledged the paradox.

“The image of Lula is in its worst shape ever, but he is still one of the strongest politicians in Brazil,” he said.

Lula’s popularity remains resilient in part because of his narrative as a president born into barefoot poverty — a rarity in a country of vast income inequality, whose leaders have come from privileged backgrounds.

Lula moved to Sao Paulo from the impoverished interior of Brazil’s northeast as a child. He became the leader of a powerful union and led several strikes during the last years of Brazil’s dictatorship before co-founding the Workers’ Party in 1980.

The party has aggressively fought the charges against Lula and Rousseff, arguing that they are politically motivated. That has galvanized the Brazilian left.

Prosecutors may have overplayed their hand at times, contributing to the doubts. The news conference last month accusing Lula of running a vast bribery scheme became the object of mockery after authorities failed to charge him with such sweeping crimes.

Still, the former president’s legal troubles are mounting. In July, Lula was accused of obstruction of justice in the Petrobras probe. In September, prosecutors charged him in connection with an apartment in the seaside resort of Guaruja they allege was renovated and given to him in return for favors by a company involved in the Petrobras case.

Lula has denied all the allegations and said he did not own the apartment. The benefits Lula is alleged to have received are worth $1.1 million, prosecutors said — far less than other politicians are accused of pocketing.

This month, Lula was also charged with crimes including corruption and money laundering in a separate investigation into contracts he allegedly obtained for a relative from a construction company. Lula denies the allegations.

At the recent rally, Lula railed against the prosecutors. But many of those attending were aware that he won’t be able to compete in the 2018 election if he is convicted or jailed.

Even here, there was some skepticism about Lula’s characterization of the charges.

“It can’t all be a lie,” said José Augusto, 21, a student working for a local leftist politician.

Nor did Lula’s campaigning help Jandira Feghali, the Communist Party candidate for mayor of Rio, who staged the rally.

She got just 3 percent of the vote.