A Spanish far-right party doubled its standing in a national election Sunday that made clear just how polarized Spanish politics has become and did little to help end the government’s long deadlock.

The results were a setback for Pedro Sánchez, the caretaker Socialist prime minister, who had hoped the election might strengthen his hand as he tries to form a new government.

The election — the fourth in four years — came after months of fruitless coalition talks between Mr. Sánchez’s party and a smaller left-wing party, Unidas Podemos .

Though Mr. Sánchez’s Socialists came out on top again, they won only 120 of the 350 seats in Parliament — three fewer seats than in April, when the last election was held.