ANTONIO COSTA, Portugal’s affable prime minister, greets your columnist with a broad grin as he settles his hefty frame into a sofa in his official residence. He has a lot to smile about. Lisbon, among Europe’s hottest tourist destinations, is enjoying a mini startup boom. Portugal’s footballers are the European champions, and its politicians have nabbed a clutch of senior international jobs. And above all, he is the winner of a high-stakes political gamble.

When Mr Costa’s Socialist Party lost an election in 2015 to the centre-right (and confusingly named) Social Democrats, who had overseen a harsh EU-imposed austerity programme during a three-year €78bn ($107bn) bail-out, most observers expected the Socialists to prop them up in a left-right “grand coalition” of the sort now common across Europe. Instead Mr Costa, the son of a communist intellectual from Goa, Portugal’s old colony in India, convinced two hard-left parties—the old-school Communists and the modish Left Bloc—to support a minority Socialist government in exchange for modest policy concessions.

Nothing like this had been tried before in Portugal. Mr Costa’s new friends wanted, variously, to write off debt, leave the euro zone, renationalise vast swathes of industry and quit NATO. The fury was swift, deep and near-universal. Foes nicknamed Mr Costa’s experiment the geringonça (“contraption”), and gave it six months at most. Portugal’s president threatened to reject the proposed government outright. Creditors feared a free-spending leftist government would send investors packing.

Yet over two years later the contraption is grinding along and the sky has failed to fall in. Some wage and pension cuts have been reversed, firms are creating jobs at a neat clip, foreign investors are eagerly sniffing around and the public finances are in rude health; the government hopes to balance the books next year. Portugal has become a bond-market darling while claiming to stand in the vanguard of the battle against austerity. “We showed that there is an alternative to ‘There is no alternative,’” says Mr Costa. He enjoys approval ratings most leaders would kill for. Little wonder Europe’s beleaguered social democrats are beating down his door.

Does Portugal have anything to teach them? Mr Costa notes modestly that “every country is specific.” Still, he has one or two ideas. Grand coalitions play into the hands of populists, he suggests, because they signal to voters that political contests are redundant. He cites Germany, the Netherlands and Austria as cautionary tales; social democratic parties in all three are floundering after governing with the right. An aide says that “civilised conflict” helps keep politics, and parties, alive. That is a bracing message in an era of cosy political pacts.

Pedro Magalhães, a political scientist at the University of Lisbon, points out that Portugal’s Socialists differ from many of their counterparts in Europe. The party sprang not from trade unions but from elites desperate to establish a bulwark against communism after the end of military rule in the mid-1970s. The party thus seeks power, not purity, and the election result gave a united left the chance to block a right-wing minority government. No one likes grand coalitions, but in many countries parliamentary arithmetic leaves centrist parties no choice but to team up against the extremes. Mr Costa’s gambit was bold, but also opportune.

The Left Bloc and the Communists hammer the Socialists on matters like foreign policy but hold fire when it matters, notably on the budget. Neither is fully comfortable with the deal, but both know they would find the centre-right alternative less palatable, and they can take credit for policies like raising the minimum wage or halting transport privatisations. Helpfully, the growth in Socialist support since 2015 has come largely at the expense of the right, soothing the leftists’ fear that the contraption would turn out to be their death warrant. Mr Costa says the arrangement will survive until next year’s election. And beyond? “Why not?”

Not a panacea

Even Mr Costa’s opponents concede that he is a canny operator. But his success has been oiled by a healthy squirt of good luck. The Socialists assumed office as Portugal’s recovery took off, aided by growth in the European markets that take 70% of its exports, and built on the measures taken by the previous government. The European Central Bank’s bond-buying had calmed markets. Tourism has boomed, thanks to instability in other warm countries. Perhaps most importantly immigration, the issue tearing apart so many European parties of the left, does not animate Portuguese voters. It is the departure of people that causes a bigger headache: during the crisis 250,000 Portuguese, disproportionately of working age, upped sticks in four years.

Portugal’s squeeze on spending had to be financed from somewhere. The axe has fallen on public investment, which was slashed in 2016 to the lowest level in the EU. Mario Centeno, the finance minister, says this was largely the result of a temporary drop in EU subsidies, and chuckles at the sight of “so-called neoliberals” who now consider Keynes their “god”. He prefers to draw attention to Portugal’s healthier banks and buzzing universities, though he adds that investment is climbing again. Another fear surrounds Portugal’s huge debt, which explains Mr Centeno’s relentless focus on the deficit.

As this suggests, Portugal’s left-wing government is thriving partly because it is not especially left-wing. For now it is fixated on deficits and debt rather than investment and public services. A centre-right government would be doing much the same. And so, despite Mr Costa’s warm words, the contraption will surely prove to be a temporary marriage of convenience; his party is already said quietly to be putting out feelers to the Social Democrats. European leftists may find inspiration in Portugal. But they will have to seek ideas elsewhere.