Spain's main party leaders have held their final rallies ahead of Sunday's election. Socialist Prime Minister Pedro Sánchez said he was confident of defying the polls. "I cannot imagine us losing," he said, posing for selfies with supporters in red T-shirts and accusing conservative rival Alberto Núñez Feijóo of planning a coalition with the far right.

Feijóo's People's Party (PP) is narrowly ahead in the polls. In the final hours of the campaign he travelled first to Barcelona and then to Seville, promising voters a new political era of "truth, decency and good governance". He accused Sánchez of evading questions on corruption, rail disasters, immigration and the national debt.

Sánchez heads one of Europe's few left-wing governments. With French presidential elections five months away, there is a real chance that two of the continent's biggest economies could move to the right in quick succession.

Almost 39 million people have a vote in Spain. Commentators expect a high turnout, while most polls have suggested a close finish. Under Spanish electoral law, no polls have been published since Monday.

"This time, yes, we're going to do it," Feijóo told PP supporters, in a nod to his failure to form a government three years ago despite winning the most seats. If he gets to form a government this time, it will be with the support of anti-immigration party Vox, led by Santiago Abascal. Vox's final rally took place in front of thousands of people in a bullring in Valencia, on Spain's east coast. The venue was filled with Spanish flags and green Vox banners.

One of the biggest cheers of the night came when party secretary general Ignacio Garriga called for "less burka and less halal". He said he was not acting out of hatred but out of love for the homeland. A small section of the crowd could be heard chanting "Viva Franco", referring to the dictator whose death in 1975 heralded the start of Spain's transition to democracy.

A number of first-time voters at the rally said they were supporting Vox because of its policies on immigration. Lledó, 18, said what happened in Ceuta in the summer, when more than 70,000 migrants crossed into the Spanish territory from Morocco, showed Sánchez was not able to control the country's border. She had come to the bullring with her mother and her aunt, Carli Chilet, who argued that Vox "are the best for women's rights".

Vox is hoping to almost double its seats from the 33 it won three years ago. It backs "national priority", putting Spanish citizens first for welfare, and "remigration" for foreigners not considered to be contributing to the economy.

The final day of campaigning followed a four-way television debate the night before that exposed Spain's sharply polarised politics. All four leaders had solutions for the housing crisis. Feijóo said the PP would build a million homes over four years, while Sánchez said housing should be a right rather than an object of speculation and profit.

While the conservatives tried to turn the spotlight on scandals that have overshadowed the Socialists' term in office, Sánchez and his left-wing ally Ada Colau, who heads Frente Amplio (The Broad Front), focused on women's rights. In the debate, Feijóo accused Colau and the rest of the left of staying quiet during a flood disaster in Valencia and briefly moved his finger to his lips. The word he used, "calladita", is a diminutive and can also be used to tell a woman to "keep quiet" in a condescending manner. Sánchez reacted immediately, called on him to show "a little respect" and accused him of sexism.

On Friday, Feijóo sought to clarify what he meant and accused Colau of remaining silent during "these years of corruption". His decision to end the campaign in Seville was significant because the wider southern region of Andalusia has 61 seats in Spain's 350-seat parliament, more than any other region. Andalusia is run by a coalition of the PP and Abascal's Vox, as are Extremadura, Aragón and Castilla y León.

Feijóo has insisted he wants to govern with a majority, backed by "parliamentary support agreements" with Vox, and says he has never spoken to Abascal about giving Vox ministerial power. "Governing is about managing, and I have spent my whole life preparing for this moment," he said in Seville.

Isabel, a retired woman, told Spanish public broadcaster RTVE that she was attending a PP rally for the first time. The formerly loyal Socialist voter said she was "disillusioned" with a party led by Sánchez. Another voter at the rally said Spain needed "a good manager".

Sánchez took to the stage in Madrid with his wife, Begoña Gómez, and put on a red T-shirt that read "power of the people". He praised Colau and her left-wing coalition's campaign. "These elections are about moving Spain forward, not taking it backwards," he said.

Socialist supporter Leon Felipe, 25, told Reuters: "Well, I think what's at stake in these elections is a big deal, is not a change of government... but rather a return to the past - a return to Franco's dictatorship." He added: "So, I believe that young must mobilise." As he was speaking, Colau told a large audience in the south of Madrid that they would "not remain silent, we will win", vowing to form another "progressive government".