By Adam Easton
BBC News, Warsaw
The conservative minority government of Poland's Law and Justice party has agreed a coalition deal with smaller Euro-sceptic and anti-reform parties.
The leaders of the three Polish parties agree the deal in Warsaw
The deal boosts its support but still denies it a working majority.
The Law and Justice party has struggled to form a coalition after a narrow win in parliamentary polls in September.
The government's alliance with populist and nationalist parties has led to fears in Brussels that Poland will be a less reliable partner in the EU.
After weeks of tense negotiations, the expected coalition failed to materialise.
At the last moment a small farmers' party pulled out, leaving the government still 13 seats short of a majority.
But Jaroslaw Kaczynski, the leader of the governing Law and Justice party, was undeterred.
He said the coalition was the basis for a stable government for the next four years.
The agreement was signed with several breakaway members of the far-right League of Polish Families and the populist rural-based party, Self Defence.
Both are Euro-sceptic and anti-reform, which has led to concern on the financial markets here and in Brussels.
It also caps a remarkable transformation for Self Defence's leader and former pig farmer, Andrzej Lepper.
He is known here for his direct action campaigns such as blocking roads and his tendency to call senior politicians bandits.
Mr Lepper, who now likes to cut a more mainstream figure, could become a deputy prime minister.
But with the recent twists and turns in Polish politics, there is every chance this coalition will not last and early elections will become a distinct possibility.