Since becoming a democracy in 1985, after 21 years of military rule, Brazil has become used to wild and unpredictable elections. But this year’s presidential race, scheduled for October 7, is one for the history books. Last July, the front-runner, former president Luiz Inácio Lula da Silva, known simply as Lula, was sentenced to 12 years in prison on corruption charges. He was accused of accepting a seafront triplex apartment from Odebrecht, Latin America’s largest construction firm, in exchange for contracts with Petrobras, Brazil’s state-run oil company. But Lula’s prosecution did not stop him from continuing his presidential run from his jail cell in the southern city of Curitiba. He abandoned the race only after the Superior Electoral Tribunal ruled, on September 11, that he could not run while serving a prison sentence. Lula’s exit from the race forced his party, the leftist Workers’ Party, or PT, into plan B: It replaced Lula with Fernando Haddad, the former mayor of São Paulo and Lula’s minister of education.

Lula’s main opponent in the race, right-wing populist Jair Bolsonaro, has created plenty of drama of his own. Internationally, Bolsonaro is mostly known for his misogyny, homophobia, and xenophobia. Among other things, Bolsonaro told Maria do Rosário, his colleague in the Brazilian Chamber of Deputies, that she was “very ugly” and therefore not “worth raping,” after she criticized the human-rights abuses of the military-dictatorship period (Bolsonaro was fined 10,000 reals, some $2,500, for his remarks); he said that he would be “incapable of loving a gay son” and that he would prefer his hypothetical gay son “die in an accident”; and he called refugees coming into Brazil from Haiti and Syria “the scum of the world.” On September 6, Bolsonaro was stabbed in the abdomen while campaigning. Because of the severity of the injuries (he reportedly lost 40 percent of his blood), Bolsonaro is staying away from the campaign trail.

Amid this political turmoil, a fire gutted Brazil’s National Museum in Rio de Janeiro, causing the destruction of thousands of irreplaceable artifacts from Brazil’s precolonial and imperial past, and one of the country’s leading centers for the study of social anthropology. The loss of the museum, the equivalent in the United States to losing the American Museum of Natural History and the Metropolitan Museum of Art in a single calamity, has forced a wrenching national debate on whether Brazil has lost its way. Peter Fry, the British anthropologist and longtime resident of Brazil, notes that the fire mirrors “a cultural environment that values the construction of glamorous football stadiums and even a museum of tomorrow in the center of Rio, but has little time for looking after the past in the present.”

As might be expected, the latest polling presents a murky picture. Bolsonaro, boosted by a wave of sympathy following his stabbing and prolonged hospitalization, leads the pack with 28 percent of likely voters; followed by Haddad with 22 percent. Left-wing populist Ciro Gomes, an academic with a history of public service, has 11 percent; and São Paulo Governor Geraldo Alckmin, a favorite of the business community and Brazil’s oligarchical media, sits in fourth with 8 percent. Environmentalist Marina Silva trails all other candidates with 5 percent. Since the winner must secure at least 50 percent of the vote, it is almost a certainty that a second round of voting will be needed to decide the eventual winner. There is a sense that anything can happen, even as polls show Bolsonaro losing to most of the other candidates in the second round of voting.

One crucial question about the presidential race, however, is not who will prevail, but how did the PT find itself in the absurd predicament of having its most viable candidate in jail? The PT should be a massive favorite in this election. This is, after all, Latin America’s largest and most successful left-wing party; a party credited with lifting some 20 million people from poverty and dramatically expanding the ranks of the middle class in the last two decades, and giving Brazil an international profile commensurate with the size and vibrancy of its economy.

At fault for PT’s travails is Lula himself, the party’s charismatic founder, its most important leader, and a larger-than-life figure in contemporary Brazilian politics. Lula rose to political prominence in the late 1970s, in the twilight of the military dictatorship, as the leader of the Steelworkers’ Union of Greater São Paulo. He used this platform to launch the PT, which from the onset broke new ground for Latin American left-wing parties. Instead of dwelling on Marxist revolutionary rhetoric, the PT emphasized using government to improve the lives of ordinary Brazilians, especially the poorest of the poor. The party also advocated for participatory democracy and embraced constituencies that at the time were on the margins of the political arena: Afro-Brazilians, indigenous peoples, the LGBT community, feminists, and the environmental movement.

But a look at Lula’s titanic legacy reveals that while the PT has been very good for Lula, he has not been equally good for the PT. For starters, Lula has blocked a whole generation of PT leaders. Since the PT’s founding, in 1980, Lula has essentially been the party’s sole standard-bearer. He ran for president three times, in 1989, 1994, and in 1998, before winning on his fourth try, in 2002. In 2010, barred from running for a third term, Lula anointed his protégé and former chief of staff, Dilma Rousseff, as his political heir. With a booming economy and wildly successful policies of wealth redistribution, Lula had almost supernatural approval ratings of more than 80 percent when he left office. His popularity helped facilitate the transfer of power to Rousseff, and so it’s hardly surprising then that PT’s foes portrayed Rousseff as merely “Lula’s puppet.” Lula unintentionally fueled this characterization by making clear that he would seek the presidency again in the future, furthering the notion that Rousseff was little more than Lula’s placeholder.

After Rousseff was impeached in 2016 for tinkering with the national budget—a process marred by widespread misogyny and sexism (previous Brazilian presidents had done the same thing that Rousseff was accused of without any consequences)—Lula quickly positioned himself as her successor, effectively freezing the presidential prospects of all other candidates within the PT. Following his sentencing, rather than focusing on his legal problems, Lula persisted with his presidential ambitions while making sure of his continued control of the party in the event that he would be barred from running. When Lula withdrew from the race, he anointed Haddad his successor in a letter that was read to hundreds of supporters who had gathered near the prison where he was being held. It noted: “Now Haddad will be Lula for millions of Brazilians.”

By using the party as a personal vehicle for his electoral ambition, Lula also undermined the PT’s development as an organization that exists apart from his own political career. As he began to climb the political ladder, Lula molded the party into a “catch-all” organization, which lacked a clear ideology (other than being vaguely progressive) but was capable of bending to his whims. During the 1994 presidential race, with an eye toward mainstreaming the party, Lula rescinded his support for abortion and gay civil unions. In the 2002 campaign, which finally brought Lula to power, Lula chose conservative businessman José Alencar as his running mate, a decision that disheartened Lula’s allies in the trade-union movement.

Policy-wise, the Lula era, 2003 through 2011, was an experiment in triangulation. He embraced the IMF, free trade, and economic integration; yet he remained lukewarm about privatization and deregulation. He was an ally of the gay community, implementing one of the world’s most effective HIV/AIDS prevention and treatment campaigns, while striking alliances with evangelical leaders notorious for their homophobia, such as Senator Marcelo Bezerra Crivella, in the hopes of cultivating support from Brazil’s evangelical community. He spoke passionately about land reform but became a booster of big agrarian interests. On foreign policy, Lula became an ally of US President Barack Obama but refrained from criticizing “brothers” Fidel Castro and Hugo Chávez.

Lula’s strategies of mainstreaming and triangulating were very effective for winning elections, but they came at the cost of developing a coherent organization with a devoted constituency. These strategies prevented the consolidation of Brazil’s left-wing firmament of political parties under a single umbrella; attempts to bring the Communists, Socialists, and the Greens under the PT umbrella never got off the ground. This fragmentation, in turn, weakened the left’s agenda in the Brazilian Congress on a whole host of issues. The most egregious is participation of women in politics, an issue on which Brazil badly trails other Latin American countries. Only 10.7 percent of the Brazilian Chamber of Deputies is female. By contrast, a robust embrace of gender quotas by left-wing parties accounts for Mexico’s 48.2 percent and Argentina’s 38.9 percent. In recent years the PT has also struggled to mobilize the social movements that built the party, such as the trade-union, gay-rights, and landless-workers’ movements.

Last, but not least, there’s the inability or unwillingness by Lula to stamp out corruption within the PT. During Lula’s first term in office, he presided over one of the biggest political scandals in Brazilian history, the mensalão, or monthly allowance, a massive kickback scheme that came close to bringing down his government. The scandal broke in 2005, when the newspaper Folha de S. Paulo reported that the PT had paid monthly payments of $13,000 to deputies from several political parties in exchange for support for the PT’s legislative program. Although the scandal did not touch Lula personally, it led to the indictment and conviction of many PT leaders and cabinet members, including José Dirceu, Lula’s chief of staff.

Rather than confronting corruption, in 2006, a reelection year, Lula distanced himself from the party and essentially ran as an independent. Lula the global celebrity rather than Lula the PT leader was front and center in that campaign. He had much to brag about. Under Lula, Brazil became a leader among the so-called BRICS (Brazil, Russia, India. and China), consolidated the country’s leadership in the Global South in efforts to curb HIV/AIDS infections, and sought a permanent seat in the United Nations Security Council. After his reelection, Lula continued to ignore corruption within the PT, while basking in global adulation. In 2009, Spain’s El País and France’s Le Monde chose Lula as their “Person of the Year”; that same year, at the G20 London summit, Obama gushed of Lula, “he’s my man.” Lula’s popularity propelled Brazil’s selection as host of the 2014 World Cup and the 2016 Summer Olympics.

After Lula was indicted on corruption charges, Rousseff and other PT bosses closed ranks to try to salvage Lula’s reputation and prevent any internal self-criticism of the party. Nothing suggests this better than Rousseff’s decision in March 2016 to name Lula her chief of staff in order to shield him from prosecution. Under Brazilian law, only the Federal Supreme Court can prosecute cabinet members. Protests erupted all over Brazil as soon as the appointment was made. It undercut Rousseff’s own commitment to fight corruption and dragged her approval ratings to record lows while feeding the criticism that her most important job as president was safeguarding Lula’s electoral viability.

A silver lining in all of this is the performance of the judiciary, traditionally the weakest branch in the Brazilian government. In recent years, the judiciary has emerged as a powerful check on the Congress and the executive branch. This, in turn, has been a massive blow to the systemic culture of graft characteristic of the country’s most powerful politicians. There’s even a term for this culture in Brazil: the jeitinho brasileiro, or the Brazilian way. This culture not only promotes corruption among the political class; it also becomes an excuse for the public to overlook corruption as long as they perceive the politicians as delivering for them.

Ironically, the transformation of the judiciary is the consequence of reforms undertaken by the PT. Lula enhanced the independence of the federal police and prosecutors; he also improved the efficacy of the courts, freeing them to pursue anti-corruption cases. On his way out of office, in 2010, Lula enacted the Clean Slate Act, which prevents candidates convicted of a crime in an appeals court from running for office. This is the same law that is now blocking Lula from the presidency. Rousseff enacted four major anti-corruption laws: the 2011 procurement reforms act; the 2011 freedom-of-information law; the 2013 organized-crime bill; and the 2013 Clean Company Act. These laws made possible “operation car wash,” or lava jato, one of the biggest corruption dragnets in modern history. Aside from Lula, the investigation has snarled Brazil’s current president, Michel Temer, and some 60 percent of the Brazilian Congress.

The PT’s best-case scenario for October 7 is for Haddad to come in second, after Bolsonaro, on the strength of Lula’s endorsement of Haddad. After that, the hope is that Bolsonaro’s toxic views and authoritarian tendencies will propel Haddad to victory in the second round of voting. Unsurprisingly, Haddad is doing his best to tie himself to Lula by arguing that Lula’s prosecution is unfair, a claim that is not without merit. Lula’s bribes (some $1.2 million) pale in comparison to the hundreds of millions of dollars that other politicians are being prosecuted for, including President Temer.

As Lula’s letter anointing Haddad the next face of the PT suggests, Lula is also doing his best to tie himself to Haddad, realizing that his legacy as well as his future is in the hands of the next president. But whether Lula can carry Haddad over the finishing line remains unclear. The Lula brand has always been about Lula the person, not Lula the party leader.