Portugal's incumbent Prime Minister António Costa greets supporters in Lisbon.Rafael Marchante / Reuters

LISBON—Across Europe, progressives have despaired the rise of the far right, over austerity policies crippling the welfare state, and of growing anti-immigrant sentiment as the region has grappled with an array of crises in recent years. Everywhere, except here.

In Portugal, a left-wing government came to power four years ago as the country was still dealing with the effects of the European debt crisis and deep spending cuts negotiated with the so-called troika—the European Commission, the European Central Bank, and the International Monetary Fund. The minority administration in Lisbon formed by Socialist Party Prime Minister António Costa was considered so unlikely to succeed that it got its own hard-to-translate, and derogatory, moniker: geringonça, which in Portuguese means an odd contraption that is very likely to fall apart. Yet the “contraption” persisted and managed to raise the minimum wage, lower unemployment, nearly eliminate the budget deficit, and maintain good relations with Brussels. In sum, it oversaw economic growth while reversing austerity policies.

That performance was rewarded at the polls over the weekend, with Costa’s Socialists winning 37 percent of the vote, up from 32 percent at the last election, in 2015. That leaves it short of a parliamentary majority on its own, but makes possible a return for what was Europe’s most left-wing government, made up of a loose alliance of Costa’s moderates with radical leftists and unreconstructed Communists (the only hard-right party to break through was Enough, which won a single seat). In their success, they have offered some hope for the left-of-center forces across the continent.

“We showed that you can improve public finances and improve living conditions for the public at the same time,” João Galamba, Costa’s secretary of state for energy, told me. “And we showed the Portuguese people that being in the European Union doesn’t only have to mean cuts.”

Politicians and political scientists here offer a set of overlapping explanations as to why the small Iberian country seems to be Europe’s least fertile ground for right-wing extremism. For one, the country has bad memories of a right-wing dictatorship that only fell in the 1974 Carnation Revolution. But there are contemporary reasons, too: Portugal’s left-wing parties have been able to maintain close ties to the country’s organized working class, a voting bloc that elsewhere in Europe has, at least in part, voted with the far right. “In this sense, the Communist Party acts as kind of a shield” against a far-right insurgence, said Pedro Magalhães, a political scientist at the University of Lisbon.

And Portugal has received a smaller influx of foreigners than have neighboring countries in recent years, meaning the right could not use immigration as a campaign issue. Indeed, Portugal is actively seeking more immigrants, Galamba told me, as an antidote to a demographic deficit caused by emigration and an aging population. Costa’s predecessor as prime minister, Pedro Passos Coelho, actually told young Portuguese people to consider leaving to look for work elsewhere, sapping confidence in the country.

“Things are not as bad as they used to be, so I decided to give the Socialists four more years,” Gabriela Cesar, a 58-year-old domestic worker, said after she cast her ballot yesterday in downtown Lisbon. She told me she previously had voted center right, and didn’t agree with the Communists or the Left Bloc on much. “But this contraption has gotten a few things done. So let’s see if they can get this country out of the ditch.”

If Portugal had the same discourse around race that the United States does, Costa would be celebrated as the country’s first prime minister of color—his father’s family is from Goa, the former Portuguese colony in western India. But his skin color was barely an issue in his two election victories, as his supporters instead stressed his practical skills as a negotiator over his identity or grand ideological vision.

Those negotiations with the left were indeed a fundamental part of Portugal’s recovery: Costa did not form a formal coalition with the Communists and Left Bloc, but they agreed to support his minority government on key votes, such as budgets, in exchange for specific agreements on wages, pensions, and small moves to reenergize the welfare state. But the Portuguese leader also benefited from favorable economic conditions, said Susana Peralta, an economist at the Nova School of Business and Economics in Lisbon. In the years since 2015, the broader European economy has grown at a decent clip, and the European Central Bank’s policy of buying up enormous quantities of government bonds to bolster the regional economic recovery has kept borrowing costs low. At the same time, the economic crisis wiped out some of the country’s poorly performing businesses, making the country more competitive. And, if anything, the inclusion of leftists in the contraption may have actually helped the economy overall, since the coalition’s anti-austerity stance put money back in regular people’s pockets and contributed to a virtuous cycle of spending. “The Socialists already planned to raise incomes,” Peralta told me, “but the left parties made them carry that out more quickly than planned.”

To be sure, Portugal is far from living through an economic boom. The minimum wage is only 700 euros (about $770) a month, youth unemployment is at 20 percent, and the country’s debt is very high, amounting to about 120 percent of gross domestic product. A small country, it also remains vulnerable to any problems that may arise internationally as a result of trade wars or problems in the EU. But Portugal nevertheless made so much progress that in January 2018, the country’s finance minister, Mário Centeno, was made president of the Eurogroup, the collection of euro-zone finance ministers. His elevation moved the Portuguese approach to the center of the European decision-making process—it was more than symbolic that Wolfgang Schӓuble, then Germany’s finance minister and regarded as among the most hawkish such politicians in the region, called him “the Cristiano Ronaldo” of European finance ministers, referencing the star Portuguese soccer player.

Across the border from Portugal in Spain, Pedro Sánchez, who faces a general election next month, has suggested forming a gobierno a la portuguesa, meaning he wants his Socialist Party to negotiate an informal ruling agreement with the left-wing Podemos group. But his country has failed to replicate Portugal’s success in forming a stable government, and such an arrangement looks unlikely to succeed.

Stability has been in short supply across much of Europe in recent years, making it all the more remarkable that Portugal has managed to achieve some measure of political predictability, fiscal responsibility, and austerity reversal—all at the same time.

“It’s not exactly a miracle, because it can all be explained,” said the political scientist Pedro Magalhães. “But it has certainly seemed miraculous that you could combine these three things.” In a recent paper, titled “Portugal’s Leftist Government: From Sick Man to Poster Boy?,” he argued that the odd center-left political solution could be reproduced in other European countries.

When he took the stage for his victory speech last night, talking to a small but packed room of supporters and journalists, Costa started humbly, saying that voter turnout, at about 55 percent, was too low. But then he turned to the insult hurled at him four years ago, that he was leading a geringonça.

“The Portuguese people liked the contraption,” Costa said, to laughs and cheers. “They really liked it, and they want continuity with the current policies.” He said he would talk to the parties on his left about forming a new government of the same type. Despite some of their more radical ideological commitments, the Left Bloc and the Communists have said they are open to working with him again. The two parties list the raising of the minimum wage, improvements to public transportation, and free textbooks for schoolchildren as successes of their participation in the past government. (The simple provision of materials to every child, regardless of background, goes a long way toward fighting prejudice at its roots, said Pedro Filipe Soares, president of the Left Bloc’s parliamentary group.)

“Revolution means economic transformation, not people in the streets with guns,” Armindo Miranda, a member of the Communist Party’s Central Committee, told me, before stopping himself. “Well, it could mean people in the streets with guns. But it doesn’t have to.”

We want to hear what you think about this article. Submit a letter to the editor or write to letters@theatlantic.com.