Five jailed Catalan separatist leaders elected to the Spanish parliament last month have been temporarily released from prison and escorted to the assembly to be sworn in as lawmakers.

The supreme court allowed the men – who are on trial for their role in Catalonia’s failed 2017 secession attempt – to leave jail to take up their seats, but they are likely to be quickly suspended because of their legal situation. They were taken back to jail after the session.

The five gained office in the 28 April general election that was won by Pedro Sánchez’s Socialist Workers’ party (PSOE), but without a majority.

Oriol Junqueras, Jordi Sànchez, Jordi Turull and Josep Rull won seats in the congress, the lower house of parliament, while Raül Romeva was elected to the senate, Spain’s upper house.

They swore to respect the Spanish constitution – which they are accused of having violated with their independence push – even as they vowed to remain faithful to the separatist cause.

“True to my republican commitments, as a political prisoner and by legal obligation, yes I promise” to respect the constitution, said Junqueras, a former Catalan vice-president who heads the separatist Republican Left of Catalonia (ERC) party.

The five are among 12 Catalan leaders on trial in connection with a banned independence referendum held on 1 October 2017 that was followed by a short-lived declaration of independence that sparked Spain’s worst political crisis in decades.

Every time one of the Catalan separatists took their oath, lawmakers from the far-right Vox party banged their desks and drowned out their voices.

Bolstered by its fierce opposition to Catalan separatism, Vox won 24 seats to become the first far-right grouping in the Spanish parliament since the death of the dictator Francisco Franco in 1975.

The conservative Popular party (PP) and centre-right Ciudadanos have said they will try to stop the five men from occupying their posts.

The PP leader, Pablo Casado, said allowing the jailed separatists to add caveats when they swore to respect the constitution was an “international embarrassment” that should not be allowed to happen again.

The chambers’ governing bodies, elected on Tuesday, will now decide whether or not to suspend the five.

“The suspension is obvious … they can’t hold their posts,” the acting deputy prime minister, Carmen Calvo, told the Cadena Ser radio station.

While the PSOE emerged as the biggest party in the 350-seat lower house in last month’s elections, it lacks a majority. If Sánchez is again to be sworn in as prime minister, he is likely to rely on some parties abstaining from voting.

But if the jailed Catalans are not allowed to take part in Sánchez’s investiture vote, and are not replaced, the threshold to be approved will be lower and he could be sworn in without relying on Catalan abstentions.

Sánchez, who took over as prime minister in June 2018, has bet on dialogue with Catalonia to ease tensions sparked by the separatist push.

Last week he proposed two Catalans as speakers of the upper and lower houses, in what was seen as a goodwill gesture.

The outgoing minister for territorial policy, Meritxell Batet, was elected speaker of congress and the philosopher Manuel Cruz was made speaker of the senate.

The ERC blocked Sánchez’s first pick for senate speaker, the Catalan Socialists leader Miquel Iceta, because he and his party backed the temporary suspension of Catalonia’s regional powers after the 2017 independence declaration.

While the ERC says it is open to dialogue with Madrid, it insists on holding an independence referendum in Catalonia, which Sánchez has refused.

A poll published on 10 May by the Catalan government’s CEO survey institute showed slightly more Catalans were against independence than were in favour – the first time that has been the case since June 2017.