Trial court judges voted to ratify a labor deal that will give most unionized court employees in San Francisco a 3 percent pay increase and a one-time $3,500 bonus. That will cost the court $4.7 million, but court officials say that’s completely offset by a reduction in the amount they’ll be required to contribute for pension and health care plans.

The new contracts represent a reversal of fortunes, both for the unions and the court. Earlier this year, the court proposed, and then unilaterally imposed, a 5 percent cut on some unionized employees. And last year, San Francisco had to go to the Judicial Council and plead for an emergency loan as it sought to bring its costs in line with cuts to its budget.

Court executive officer T. Michael Yuen said that after making painful cuts, including eliminating 11 commissioner positions and closing six courtrooms, San Francisco has steadied its finances and can afford the bonuses. It paid back the loan this summer. And this year the governor included a provision requiring local courts to surrender unspent reserves.

Still, the raises could become a headache for Yuen and the local judges. Last year, some on the Judicial Council said San Francisco was to blame for its budget shortfalls and suggested its employees were overpaid.

Councilman David De Alba, a Sacramento County Superior Court judge, said Wednesday that it will “not go unnoticed” that San Francisco Superior Court has money to spend on wage hikes while many other county courts “barely have enough money to keep doors open.”

Steve Stallone, a spokesman for employees represented by the Service Employees International Union, said Tuesday’s ratification was expected. But he disputed the notion that court officials had won reductions in pension contributions, saying those adjustments were required by law and not a part of the negotiations.

The new contract is effective as of November 13 for SEIU members. The contract with the other three unions, including the court reporters’ union and a managers’ union, will go into effect early next year. A court official said the $3,500 bonuses will be paid out early next year as well.