HARTFORD — Threatened with nearly 5,000 layoffs, representatives for 45,000 unionized state employees agreed Friday to $1.6 billion in concessions over two years to help balance a budget that Gov. Dannel P. Malloy says includes pain for everyone: record tax increases, substantial program cuts and worker givebacks in health care, pension benefits and wages.

Mr. Malloy announced the deal after two months of negotiations and the passage of a budget last week that assumed concessions before they were accepted by the unions. He said the deal, which is still subject to ratification by workers, would save Connecticut taxpayers $21.5 billion over 20 years through structural changes in employee compensation.

The governor, a Democrat who won election in November with strong union support, has carved out a national niche as a politician seeking an approach to state governance different from the confrontational stances taken by Republican counterparts like Chris Christie in New Jersey and Scott Walker in Wisconsin. Despite layoff notices that started going out this week, Mr. Malloy and labor leaders maintained a cordial public tone throughout the bargaining.

Mr. Malloy hailed the deal as “historic because of the way we achieved it — we respected the collective-bargaining process and we respected each other, negotiating in good faith, without fireworks and without anger.” He also called the deal “the most significant agreement with state employees in Connecticut history” for its long-term approach.