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.