If Spain’s national elections on Sunday turn out as most polls and analysts suggest, mainstream conservatives may come out on top but need allies on the political fringe to govern, ushering the first hard-right party into power since the Franco dictatorship.

The potential ascent of that hard-right party, Vox, which has a deeply nationalist spirit imbued with Franco’s ghost, would bring Spain into the growing ranks of European nations where mainstream conservative parties have partnered with previously taboo forces out of electoral necessity. It is an important marker for a politically shifting continent, and a pregnant moment for a country that has long grappled with the legacy of its dictatorship.

Even before Spaniards cast a single ballot, it has raised questions of where the country’s political heart actually lies — whether its painful past and transition to democracy only four decades ago have rendered Spain a mostly moderate, inclusive and centrist country, or whether it could veer toward extremes once again.

Spain’s establishment, centrist parties — both the conservative Popular Party and the Socialists led by Prime Minister Pedro Sánchez — have long dominated the country’s politics, and the bulk of the electorate seems to be turning away from the extremes toward the center, experts note.

But neither of Spain’s mainstream parties has enough support to govern alone. The Popular Party, though predicted to come out on top on Sunday, is not expected to win a majority in the 350-seat Parliament, making an alliance imperative. The hard-right Vox is its most likely partner.

The paradox is that even as Vox appears poised to reach the height of its power since it was founded a decade ago, its support may be shrinking, as its stances against abortion rights, climate change policies and L.G.B.T.Q. rights have frightened many voters away.

The notion that the country is becoming more extremist is “a mirage,” said Sergio del Molino, a Spanish author and commentator who has written extensively about Spain and its transformations.

The election, he said, reflected more the political fragmentation of the establishment parties, prompted by the radicalizing events of the 2008 financial crisis and the near secession of Catalonia in 2017. That has now made alliances, even sometimes with parties on the political fringe, a necessity.

He pointed to “a gap” between the country’s political leadership, which needed to seek electoral support in the extremes to govern, and a “Spanish society that wants to return to the center again.”

José Ignacio Torreblanca, a Spain expert at the European Council on Foreign Relations, said the messy process of coalition building in the relatively new Spanish era of the post two-party system lent leverage and visibility to fringe parties greater than their actual support.

“This is not a blue and red country, at all,” he said.

Other were less convinced. Paula Suárez, 29, a doctor and left-wing candidate for local office in Barcelona with the Sumar coalition, said the polarization in the country was entrenched. “It’s got to do with the civil war — it’s heritage. Half of Spain is left wing and half is right wing,” she said, calling Vox Franco’s descendants.

But those who see a mostly centrist Spain use the same historical reference point for their argument. The Spanish electorate’s traditional rejection of extremes, some experts said, was rooted precisely in its memory of the deadly polarization of the Franco era.

Later, through the shared traumas of decades of murders by Basque terrorists seeking to break from Spain, the two major establishment parties, the Popular Party and the Socialists, forged a political center and provided a roomy home for most voters.

But recent events have tested the strength of Spain’s immunity to appeals from the political extremes. Even if abidingly centrist, Spanish politics today, if not polarized, is no doubt tugged at the fringes.

A corruption scandal in the Popular Party prompted Vox to splinter off in 2013. Then the near secession of Catalonia in 2017 provided jet fuel to nationalists at a time when populist anger against globalization, the European Union and gender-based identity politics were taking off across Europe.

On the other side of the spectrum, the financial crisis prompted the creation of a hard left in 2015, forcing Mr. Sánchez later to form a government with that group and cross a red line for himself and the country.

Perhaps of greater consequence for this election, he has also relied on the votes of Basque groups filled with former terrorists, giving conservative voters a green light to become more permissive of Vox, Mr. Torreblanca said. “This is what turned politics in Spain quite toxic,” he said.

After local elections in May, which dealt a blow to Mr. Sánchez and prompted him to call the early elections that Spaniards will vote in on Sunday, the conservatives and Vox have already formed alliances throughout the country.

In some cases, the worst fears of liberals are being borne out. Outside Madrid, Vox culture officials banned performances with gay or feminist themes. In other towns, they have eliminated bike paths and taken down Pride flags.

Ester Calderón, a representative of a national feminist organization in Valencia, where feminists marched on Thursday, said she feared that the country’s Equality Ministry, which is loathed by Vox, would be scrapped if the party shared power in a new government.

She attributed the rise in Vox to the progress feminists had made in recent years, saying it had provoked a reactionary backlash. “It’s as if they have come out of the closet,” she said.

At a rally for Yolanda Díaz, the candidate for Sumar, the left-wing umbrella group, an all-woman lineup talked about maternity leave, defending abortion rights and protecting women from abuse. The crowd, many cooling themselves with fans featuring Ms. Díaz in dark sunglasses, erupted at the various calls to action to stop Vox.

“Only if we’re strong,” Ms. Díaz said, “will we send Vox to the opposition.”

But members of the conservative Popular Party, which is hoping to win an absolute majority and govern without Vox, have tried to assure moderate voters spooked by the prospect of an alliance with the hard right that they will not allow Vox to pull them backward.

Xavier Albiol, the Popular Party mayor of Badalona, outside Barcelona, said that “100 percent” there would be no backtracking on gay rights, women’s rights, climate policies or Spain’s close relationship with Europe if his party had to bring in Vox, which he called 30 years behind the times.

Vox, he said, was only interested in “spectacle” to feed their base, and would merely “change the name” of things, like gender-based violence to domestic violence, without altering substance.

Some experts agreed that if Vox entered the government, it would do so in a weakened position as its support appears to be falling.

“The paradox now,” said Mr. Torreblanca, the political analyst, is that just as Mr. Sánchez entered government with the far left when it was losing steam, the Popular Party seemed poised to govern with Vox as its support was sinking. “The story would be that Spain is turning right. When in fact this is the moment when Vox is at the weakest point.”

Recent polls have shown voters turning away from Vox, and even some of its supporters did not think the party should touch the civil rights protections that Spain’s liberals introduced, and that its conservatives supported.

Gay marriage “should remain legal of course,” said Alex Ruf, 23, a Vox supporter who sat with his girlfriend on a bench in Barcelona’s wealthy Sarriá district.

Mr. Albiol, the mayor of Badalona, insisted that Spain was inoculated, and said that unlike other European countries, it would continue to be.

“Due to the historical tradition of a dictatorship for 40 years,” he said, Spain “has become a society where the majority of the population is not situated at the extremes.”

That was of little consolation to Juana Guerrero, 65, who attended the left-wing Sumar event.

If Vox gets into power, they will “trample us under their shoes,” she said, grinding an imaginary cigarette butt under her foot.

Rachel Chaundler contributed reporting.