The victory of Brazil's far-right presidential candidate Jair Bolsonaro has battered the country's leftist Workers Party, which is now looking for a way to rebuild.
After defining Brazilian politics for much of the past two decades, the party is still ruled by its imprisoned 73-year-old founder, threatened by internal divisions and concentrated in a region far from the centre of economic power.
The damage goes beyond the drubbing voters delivered to the party's presidential candidate Fernando Haddad, who lost by a 10-percentage-point margin in Sunday's election.
For millions of Brazilians, the PT, as the Workers Party is known, has become synonymous with corruption and mismanagement. PT governments in recent years presided over the biggest bribery scandal in the nation's history and the worst economic downturn since the Great Depression. Street crime has also exploded.
The backlash has been severe. Former President Luiz Inacio Lula da Silva - whom Barack Obama once dubbed "the most popular politician on Earth" - sits in a prison cell, serving a 12-year sentence for graft and money laundering. Lula's hand-picked successor, former President Dilma Rousseff, was impeached for fudging public accounts.
Angry voters responded by throwing their support to Bolsonaro, including sizeable numbers of low-income workers, Afro-Brazilians and university students who were long the PT's core supporters. The bombastic former Army captain tapped into their fury, vowing to crack down on criminals, be they in the streets or in the halls of Congress.
Even some voters nervous about Bolsonaro - who has urged police to shoot to kill and vowed to jail or drive his political foes out of the country - chose him as an insurance policy to keep the PT from returning to power.
Brazilian hip-hop icon Mano Brown chastised party leadership as being out of touch with voters at a star-studded concert and PT rally in Rio de Janeiro just days before Sunday's wipeout.
"There is no reason for us to celebrate," Brown told the crowd as stunned dignitaries, including Haddad and famed singer-songwriters Caetano Veloso and Chico Buarque, looked on. "If you can't speak the people's language, you're going to lose big."
'PROJECT FOR POWER'
Corruption in Brazilian politics existed long before the PT was formed in 1980 to unite union workers, artists and intellectuals to help end Brazil's 1964-1985 dictatorship.
All of the country's major political parties, not just the PT, are implicated in the so-called Operation Car Wash investigation that ensnared Lula. PT loyalists say he and Rousseff were the victims of a right-wing "coup" that sought to discredit their leadership and undo social programs that lifted millions from poverty and gave minorities a seat at the table.
But even some PT stalwarts admit its rise from an opposition party to a governing one caused it to lose touch with its roots. Horse trading in the capital Brasilia became paramount for the party to stay on top, said Carlos Alberto Libanio Christo, a Roman Catholic priest and founding member of the PT who is known in Brazil as Frei Betto.
"Gradually, the PT traded its project for Brazil in favour of a project for power," said Frei Betto, who spent four years imprisoned during the dictatorship. "The party disappeared from the countryside and the poor urban outskirts."
Another major challenge is that the PT is dwarfed by the towering presence of Lula, who still runs the show from jail.
Barred from running for another term due to his felony convictions, Lula tapped Haddad, the former mayor of Sao Paulo, as his stand-in, a gambit that failed miserably.
Lula loyalists, including Washington Quaquá, the head of the PT in Rio de Janeiro state, are sticking with Haddad despite his resounding defeat.
"Haddad came out of this election a great leader," Quaquá said. "He emerged with the stature needed to be our national leader."
But a militant faction of the PT is pushing for more aggressive leadership. Some grouse that Haddad, a mild-mannered political science professor at the elite University of Sao Paulo, is not tough enough to take on Bolsonaro.
Gleisi Hoffman, currently the president of the party, had resisted putting Haddad at the top of the ticket until Lula told her to fall in line, according to party members familiar with the internal debate.
The news for the PT is not entirely dismal.
The party won the most seats in the lower house on Sunday. It also took four governorships, more than any other party, although all were concentrated in Brazil's poor northeast, a traditional PT stronghold.
After the shock of Bolsonaro's big win dissipates, the PT will unify and embrace its role as the resistance, with Haddad at the helm, predicted Alberto Almeida, the founder of Brasilis, a political and social analysis firm in Sao Paulo.
"After all, he did win 45 million votes," Almeida said.
He said the PT's mission will be to confront a challenge not seen since Brazil's return to democracy three decades ago: combating an "extreme-right leader."
"In that way, the PT's role is similar to what the Democrats in the U.S. are facing with Trump," Almeida said.
Haddad signalled as much in his concession speech in Sao Paulo, issuing a rallying cry to a movement in disarray.
"All of us here, who helped build one of the world's largest democracies, must maintain it in the face of provocations and threats," Haddad said. "Have courage. The key to life is courage."
(With inputs from agencies.)