BARCELONA (Reuters) - Catalonia's outgoing president said on Monday he would quit politics after his separatist party's disastrous showing in the region's election that saw Spain's Socialists deliver an historic upset to the independence movement.

Pere Aragones's moderate Esquerra Republicana de Catalunya (ERC) remains the best hope for the Socialists, who won the most votes in Sunday's election but fell short of a majority, to form government in the prosperous northeastern region.

Aragones, who has led Catalonia for three years, said his party would not back the Socialists, telling them to call on hardline separatist party Junts instead.

"ERC will remain in opposition, which is where citizens have placed us," he told reporters.

The Socialists, led locally by Salvador Illa, had 42 seats in Catalonia's 135-seat chamber with more than 99% of the vote counted, while its habitual coalition partner, far-left Sumar, won six. Junts had 35 seats, and ERC had 20.

To win an investiture vote to form government, parties must have 68 seats in the first round and a simple majority in the second.

Senior Socialist official Nuria Parlon told reporters their preferred option was a leftist agreement with ERC and Sumar, with a minority government backed by other parties as an alternative.

The regional vote also has implications for the stability of the national government.

ERC has presided over a period of calming tensions with Spain's Socialist-led central government following the turbulent years after Catalonia held an illegal independence referendum in 2017 and briefly declared independence, sparking a constitutional crisis.

PARDONS

Prime Minister Pedro Sanchez has pardoned separatist leaders convicted over the independence drive and offered a controversial amnesty to others still being prosecuted. ERC has in turn backed Sanchez's minority government nationally.

The fruits of that more conciliatory approach were reflected in Sunday night's good result for the Socialists, while the ERC lost significant support.

Now, it must decide whether to remain firm in rejecting the Socialists' overtures to support it to form a government, potentially forcing a fresh vote.

Ignacio Jurado, a political scientist from Carlos III University in Madrid, said ERC may decide its voters may have punished it for having too friendly relations with Madrid, and up the price of its support both at a regional and national level. Demands have in the past included control of the region's train network and taxes.

The more hardline separatist Junts party has also backed the minority Socialist national government.

But its leader Carles Puigdemont told reporters on Monday that he would not support the formation of a regional Socialist government and if the Socialists turned instead to the conservative People's Party, Junts would withdraw its backing for national government too.

Cristina Monge, an independent political analyst, said the continued support of the ERC and Junts was crucial for the stability of Spain's national government.

"If one of them, Puigdemont probably, is not included in any way in the Catalonia agreement, he could put the Spanish government in a very difficult position," she said.

(Reporting by Joan Faus and Belen Carreno, Writing by Aislinn Laing,; Editing by Andrew Cawthorne)

By Joan Faus