Spain voted to oust its beleaguered socialist prime minister in Sunday's parliamentary election, paving the way for a new conservative government – and inviting the return of the far right to power for the first time since Franco.

Spaniards had turned out in record numbers to vote in the snap election, which leader Pedro Sanchez called last month after struggling to garner support in tackling a prickly housing crisis still generating major protests.

The centre-right People's Party (PP) claimed victory as night fell on Madrid, with crowds of supporters gathering outside the party headquarters as early results sketched a resounding defeat for Mr Sanchez's PSOE party.