MADRID (AP) — The rhetoric in Spain's political crisis, in which Prime Minister Mariano Rajoy is almost certain to lose a no-confidence vote Friday amid a corruption scandal engulfing his party, is turning ugly.

Rajoy's government and his ruling Popular Party, or PP, have been labelled "zombies" in an editorial by leading daily El Pais.

The PP then struck back, saying the alternative would be for opposition Socialist leader Pedro Sanchez to head a "Frankenstein government" supported by anti-establishment and regional politicians that would be doomed to failure.

While Rajoy looks likely to be unseated by the Socialist party which presented the no-confidence motion, the veteran politician isn't going down without a fight. With stability in the eurozone's No. 4 economy at stake, here's a look at how the political crisis formed and how it might unfold:

DAMAGING COURT RULING

A Spanish court dealt a huge setback to the Popular Party last week, putting Rajoy under the microscope.

National Court judges delivered hefty prison sentences to 29 businesspeople and PP members, including some elected officials, for fraud, money laundering and tax evasion, among other crimes.

The high-profile case has captivated Spain since the first allegations emerged in 2013 and led to the arrest of PP senator and longstanding treasurer Luis Barcenas. During the high-profile investigation, Barcenas testified that the PP kept a slush fund with donations from private business owners and that some party officials received non-taxable bonuses in addition to their salaries.

Spanish media dissected the case, from an unprecedented raid at PP's national headquarters, to the destruction of hard drives there, and even published a barrage of private messages between Rajoy and Barcenas.

Last week's National Court ruling looks at only one portion of the case, the kickbacks-for-contracts scheme in place between 1999 and 2005, when Rajoy himself was moving up the party ladder.

PP was fined 245,000 euros ($287,000) for benefiting from "an authentic and efficient system of institutional corruption." But perhaps more damagingly for Rajoy, they also questioned the prime minister's credibility and other PP witnesses when they said in court that the hidden accounting was unknown to them.

___

THE MOTION AND THE PARTIES

All major parties have called for Rajoy to step down, but the prime minister has fended off pressure saying that political instability is bad for the country and for the economies in Spain and the European Union.

He also cancelled his public agenda this week — even calling off a trip to Kiev last weekend that ended with him missing Real Madrid's victory in the Champions League final — to prepare for Thursday's no-confidence debate and Friday's vote.

In Spain, a no-confidence motion is designed not just to oust the standing prime minister but to choose a replacement. As the second most voted party in the 2016 election, the Socialists proposed Sanchez, who regained the party leadership last year after an internal revolt that sidelined him for months.

Backed by his party and the far-left anti-establishment Podemos, Sanchez on Thursday successfully convinced Catalan and Basque nationalist lawmakers to support his government plan, giving him the absolute majority in the 350-seat Congress of Deputies he needs to replace Rajoy.

Ciudadanos, a rising star in the center-right of Spanish politics, is refusing to support him and is seeking a new general election instead that could be won by their leader, Albert Rivera, according to recent polls.

The pro-business party is riding a wave of popularity especially after it pressed Rajoy for a more aggressive approach against the Catalan separatist challenge. Rivera would have strong chances of placing first in an election, positioning him to become prime minister but without winning a majority to form a government on its own.

___

POSSIBLE OUTCOMES

The key is in the hands of the Basque Nationalist Party, or PNV, which decided to back Sanchez with its five lawmakers in the national parliament after the Socialist leader vowed to keep the hefty benefits that the Basques obtained in the recent negotiations of the 2018 national budget. The prospect of an election won by Ciudadanos, which opposes concessions to the nationalists, is one of the PNV's worst nightmares.

If against expectations Rajoy survives, both Ciudadanos and Podemos have announced they would then follow up with subsequent no-confidence votes in order to call an immediate general election, possibly in the fall.

"Rajoy might survive for a while, because it's very difficult that the other parties can come to an agreement to remove him," said Andrew Dowling, an expert in Spanish politics at Cardiff University in Wales. "But it's definitely the beginning of the end of Rajoy and his Popular Party."

If he wins, Sanchez would take over from Rajoy immediately and possibly be sworn in as early as next Monday. But a minority Socialist Cabinet would be a "Frankenstein government," as the Popular Party has characterized it, with hard to please nationalists and anti-austerity lawmakers.

A third possibility, an early resignation by Rajoy himself to avoid the embarrassment of being ousted, was rejected Wednesday by the prime minister's office in a statement.

Rajoy, the statement said, "has done nothing that justifies stepping down. It would be acknowledging guilt."