The centrist Civic Coalition got 27.4 per cent while the left-wing Lewica alliance scored 12.6 per cent. Next came the PSL-Kukiz’15 alliance of agrarians and populists with 8.6 per cent and the far-right Confederation with 6.8 per cent.

That translates into 235 seats for PiS, 134 for Civic Coalition, 49 for Lewica, 30 for PSL-Kukiz’15 and 11 for Confederation, the Polish electoral commission said on Monday.

Poland’s system for counting seats in the Sejm favours the largest party. PiS benefited from the backing of 8,051,000 voters versus 8,957,000 for the democratic opposition (comprising the three formations entering parliament minus the far-right Confederation).

The upshot was a five-seat majority for PiS.

“We are very happy,” PiS leader Jaroslaw Kaczynski said on Monday night after the final results. “We received legitimacy to continue to change Poland, to continue the ‘good change.’”

His upbeat tone contrasted with a more muted response to exit polls on Sunday night, when Kaczynski told supporters at party headquarters: “We are a political formation which deserves more. We got a lot, but we deserve more.”

Why would Kaczynski not be ecstatic?

While PiS won the Sejm — allowing it to form the government — it lost the Senate upper house, by just one seat.

Poland’s 100 senators are elected using a first-past-the-post system. The three main democratic opposition forces (Civic Coalition, Lewica and PSL-Kukiz’15) had made a pact not to field candidates against one another. And the strategy worked.

The democratic opposition and independents supporting it will have 51 seats in the new Senate, compared with 49 for PiS allies.

This is important.

While the Senate is the least influential of the two houses in parliament, the fact that it remains in the hands of the opposition means it will be impossible for PiS to pass important legislation overnight, with no public scrutiny, as it did with controversial justice reforms in the first year of its initial stint in power.

The Senate at least has the power to hold up legislation it does not like or it considers unconstitutional — opening the door to greater scrutiny of executive action.

Moreover, the Senate controls appointments to key institutions, allowing it to safeguard their independence.

In his speech on Monday, Kaczynski said he hoped the Senate would become a place where “political war will be limited”.

To critics, this was sour grapes. They say that when the Senate was under PiS control, the ruling party had no problem in picking fights with the opposition.

Analysts say the fact that the democratic opposition got more votes than PiS also casts next year’s presidential elections in a new light, with the opposition sniffing possible victory.

Meanwhile in the Sejm, PiS’s five-seat majority is not enough for a constitutional majority nor strong enough to counter any presidential veto.

Were the opposition to win presidential elections next year, PiS’s control of the Sejm would suddenly mean far less than it does today.

Despite its improved vote count, PiS has the same number of seats it got four years ago due to a higher turnout than in 2015.

And it is a fragile majority.

It is important to note that PiS got this many seats as part of a coalition. Called “United Right”, the coalition included two other parties — one led by maverick conservative Jaroslaw Gowin and the other by Kaczynski’s close ally, Justice Minister and Prosecutor General Zbigniew Ziobro.

Without Gowin and Ziobro, PiS would only have secured 200 seats, as the two formations combined got 35 places in the Sejm.

And while Ziobro is likely to remain faithful to Kaczynski, Gowin’s allegiance is not guaranteed. He was, after all, once a minister in the Civic Platform government led by Donald Tusk, president of the European Council.

“The results of the elections are profoundly paradoxical,” said Jakub Majmurek, a political commentator for Krytyka Polityczna. “On the one hand, PiS won more than 8 million votes … more than any other party achieved since 1989. It should be seen as a great success. However, I think it is not, nor does Kaczynski.”

He added: “Despite the very strong economy, the generous social handouts, the shameless pro-government propaganda on public TV and radio, PiS failed to secure the support of the majority of the electorate. It’s hardly possible that Kaczynski will ever get a better chance to gain more votes. It seems that the whole ideological project of PiS has just hit its glass ceiling.”

Before the election results were announced, and with opinion polls pointing to a more emphatic victory for PiS, analysis warned that the party’s next goal could be to complete its takeover of the judiciary and to hit back at private media critical of the government.

While some argue that a weaker grip on power might make the party act tougher and faster, in a desperate bid to cement its control, others say the current configuration in parliament will at least ensure there is resistance to any further attempts to control independent institutions.