By Adam Easton
BBC News, Warsaw
Poland's ruling Law and Justice party has reached a deal to revive the coalition government, staving off the possibility of early elections.
Mr Kaczynski's party has been hit by a corruption scandal
Under the agreement, Andrzej Lepper, who leads the Self-Defence party, was reappointed deputy prime minister and agriculture minister.
The party left the coalition last month when Mr Lepper was dismissed from his posts after rows within the alliance.
Elections are not scheduled for another three years.
Mr Lepper's return to the government just three weeks after he was unceremoniously dumped is one of the more spectacular U-turns in recent Polish political history.
At the time of the dismissal, Prime Minister Jaroslaw Kaczynski accused Mr Lepper of "squabbling" for repeatedly criticising the government over its failure to increase social spending and the decision to send additional troops to Afghanistan.
But since then the popularity of Mr Kaczynski's conservative Law and Justice party has slumped amid a high-profile corruption scandal.
Mr Kaczynski had been under pressure to revive the coalition because Poland's parliament was due to vote on Tuesday on an opposition-sponsored motion to dissolve itself and hold snap elections.
This new agreement means that the government will be able to vote down that motion.
But it does not mean it will have a majority in parliament.
The three coalition partners are one seat shy of a majority and talks with a fourth grouping are expected to take place later this week.