Artur Mas during his press conference. G. Battista

After months of negotiations, the pro-independence Junts pel Sí bloc and the anticapitalist Candidatura d’Unitat Popular (CUP) have reached a final-hour deal to invest a new premier in Catalonia and avoid fresh regional elections.

Under the terms of the pact, which was reached on Saturday just 30 hours before the deadline to choose a leader was due to expire, the mayor of Girona, Carles Puigdemont, will become the new Catalan premier with current acting regional chief Artur Mas stepping down. The CUP will also hand over two of its deputies to work within the Junts pel Sí coalition.

The decision represents a U-turn for Mas, who since his Junts pel Sí bloc won the September regional election had always insisted that he would not step aside

The decision represents a full U-turn for Mas, who in the three months since Junts pel Sí – which comprises his own Democratic Convergence (CDC) party, the Catalan Republican Left (ERC) and other pro-sovereignty groups – won the regional election had always insisted that he would not step aside in favor of a consensus candidate, as the CUP had demanded.

The small pro-independence, anticapitalist party’s 10 elected deputies held the key to power in the region after Mas’s separatist coalition failed to attract enough votes for an absolute majority at the September 27 election.

“The agreement allows us to work,” Mas said in reference to the independence process as he appeared before reporters to explain the deal on Saturday afternoon.

In his address Mas admitted that the decision was “painful” but that he was convinced that his resignation was positive for pushing ahead with the independence process, and for Catalonia. “The country is the first thing,” he said.

He underscored that he would not be taking on another role in exchange for stepping down, but that he would remain at the disposal of the Catalan parliament and the future premier and regional government.

The plan is that Puigdemont, also of Mas’s CDC party, will on Sunday be elected premier in the first round of voting by an absolute majority. That implies that he would receive the votes of the 62 Junts pel Sí deputies in the Catalan parliament and two of the 10 CUP members.

Although Mas had already announced on Monday that he was resigned to there being new elections in Catalonia, negotiations between the two forces had continued throughout the week. But it was only on Saturday that the deadlock finally broke and the possibility of Mas stepping down was placed on the table.

What happened to make Mas change his mind? The CDC leader responded to the question by explaining that “time and events have progressed and something that could hardly be foreseen occurred, and that is that there is a stable agreement on everything by everyone.”

“What also changed is that the CUP admitted its own mistakes,” he added. “No new concessions have been given to the CUP. I have taken a political decision that I did not have to take. The election was an option, but not a good option.”