BARCELONA, Spain (AP) — Spain's caretaker prime minister will face important parliamentary votes this week that will either endorse his Socialist Party to form a new government, or push the country closer to a possible fourth general election in five years and even more political instability.

Pedro Sánchez will have two opportunities to win the support of the members of parliament's lower house, but he enters the week without assurances that he has the votes.

The Socialists are working against the clock to strike a last-minute deal with the far-left United We Can that would bring the anti-austerity party into Spain's first coalition government since the restoration of democracy more than four decades ago.

Yet even with United We Can on board, Sánchez will still need the help of some smaller parties.

A failure by Sánchez would start a two-month countdown for a new government to be formed. After that, Parliament would automatically be dissolved and a new election called.

HOW DID SPAIN GET HERE?

Sánchez took charge a year ago when he ousted conservative predecessor Mariano Rajoy, who lost a no-confidence vote following a damaging verdict in a corruption case that involved Rajoy's Popular Party.

Sánchez kept afloat a minority government until right-wing parties and Catalan separatists scuttled his national spending bill in February. Sánchez responded by calling an early election for April 28, when his Socialists got the most votes by a long margin but still fell short of a majority.

HOW CAN SÁNCHEZ REMAIN IN POWER?

Sánchez will have two chances to win the backing of the parliament this week.

Following a parliamentary debate on Monday, Sánchez will face a vote Tuesday in which he needs to win an absolute majority of 176 seats of the 350-seat chamber.

If he comes up short, he will have another opportunity on Thursday, when the bar is lower and he will only need to win more "Yes" votes than "No" votes.

The Socialists hold 123 seats and United We Can has 42, giving them 165 between them. So Sánchez would still to convince smaller regional parties to help him at least in the second vote to overcome the guaranteed "No" votes from the Popular Party, the center-left Citizens party, far-right Vox party and other smaller parties on the right.

LAST-MINUTE DEALS

Negotiations between the Socialists and United We Can were going nowhere until the latter's leader, Pablo Iglesias, announced Friday that he would cede to Sánchez's demand to not seek a seat in his Cabinet.

The Socialists responded by saying they are now optimistic that they can work out a rushed deal to agree on central policy priorities, but United We Can still insists on having ministers in the Cabinet.

In 2016, United We Can also held the key to Sánchez's chances of forming a government following an inconclusive election, only to sink his candidacy and force a new election that led to Rajoy staying in power.

WHAT HAPPENS IF SÁNCHEZ FAILS?

If Sánchez can't win the confidence of lawmakers in either vote, the next step would be for King Felipe VI to call another round of talks with the leaders of all the parties in the lower chamber and then name a candidate to try to form government.

Sánchez could accept a second candidacy, or another leader such as the Popular Party's Pablo Casado could give it a try, despite not having enough potential support from right-wing parties alone.

The deadline for another investiture attempt would be Sept. 23. After that, Spaniards would be called back to the polls, likely in November.

Many in Spain argue that the country can ill afford not having a stable government in place before the verdict of the Catalan secession trial that is expected in the fall, possibly in September.

A heavy punishment for the 12 leaders of the 2017 Catalan breakaway attempt would likely fire up tensions with the separatists, who still hold power in the regional government in Spain's wealthy northeastern corner.

Copyright 2019 The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed.