People across Spain have cast their ballots for the second time in six months, in a closely watched election just days after Britain's decision to exit the European Union.

Polls closed at 8pm (18:00 GMT) for Spain's roughly 36.5 million voters on Sunday, with results expected shortly.

Sunday's repeat vote came after the four main political parties failed to agree on a coalition after December's general election resulted in a hung parliament.

Yet, opinion polls suggested the new ballot might also not break the political deadlock.

The conservative Popular Party (PP) was expected to come again first without a majority, while the on-the-rise left-wing Unidos Podemos alliance was tipped to overtake the centre-left Socialists in second place.

The centrist, business-friendly Ciudadanos was expected to come fourth.

The Socialists and Unidos Podemos could potentially create a broad left-of-centre coalition.

Al Jazeera's Neave Barker, reporting from Spain's capital, Madrid, said there was a lot at stake in this general election.

"Spanish people are going back to the polls for the second time in six months. They are fed up and they want to put an end to this political impasse."

Crucial vote

Britain's surprise vote on Thursday to leave the EU has further added to the uncertainty, with the PP insisting on the need for "stability" in the face of "radicalism" and "populism".

It was a jab at the Unidos Podemos coalition, which rejects EU-backed austerity and pledges to fight for the least well-off.

"If you want a united country and not a radical Spain, think about it, go for what is safe ... vote for the Popular Party," Mariano Rajoy, acting prime minister, said in one of his last comments on Twitter before the obligatory day of campaign silence.

The Unidos Podemos coalition, led by Pablo Iglesias, has responded with a message of calm aimed at defusing this criticism.

The left-wing alliance - the "o" of Unidos shaped as a heart - has made "smile of a country" its slogan for an emotional campaign.

"Thank you. For everything," Iglesias said in his final campaign-related tweet, a picture of him from the back, raising his fist towards a crowd.

OPINION: Spain, a non-governmental organisation?

Rajoy argued that since the PP came to power in 2011, it has brought Spain back to growth and overseen a drop in unemployment - though at 21 percent, it was still the second highest rate in the EU after Greece.

But his rivals retort that inequalities have risen and the jobs created are mainly unstable.

The PP has also been engulfed by corruption scandals in recent years, with jailed party treasurer Luis Barcenas telling investigators about a scheme of illegal contributions and donations to the party.

The Socialists were fighting smaller scandals of their own, involving allegations that former party members ran a fraud scheme by siphoning off public funds.

After the vote, political leaders were expected to head back to the negotiating table, under more pressure this time to form a coalition.