In a victory for farm worker unions, the California Supreme Court on Monday upheld a state law requiring employers in a farm labor dispute to accept the terms of a contract ordered by a state mediator after negotiations fail to produce an agreement.

The law, passed in 2002, was declared unconstitutional in 2015 by a state appeals court, which said it discriminated against growers and improperly allowed the state farm labor board, and its mediator, to impose binding contracts that had not been negotiated. But the state’s high court ruled unanimously that the law was a neutral measure designed to speed up the pace of farm labor collective bargaining in California.

The state in 1975 passed the nation’s first law giving farm workers the right to join unions and negotiate with growers but, as of 2002, only 40 percent of agricultural employers had agreed to contracts with unions their employees had chosen, the court said. The 2002 law allowed either side to seek a mediator who would oversee negotiations, and then, if no agreement was reached, to order a contract that would consider both sides’ needs and would be subject to farm labor board review.

The rational purpose of the law is “to promote collective bargaining and ensure stability in the agricultural labor force,” Justice Goodwin Liu said in the 7-0 decision. He said the law allows the opposing sides to agree on a mediator and appeal the mediator’s rulings, and contains safeguards to “prevent misconduct, favoritism, or abuse of power by the mediator.”

The grower in the case, Gerawan Farming, said it would seek review in the U.S. Supreme Court.

“Coerced contracts are constitutionally at odds with free choice,” said Gerawan, a tree and grapefruit grower with 3,000 employees in Fresno and Madera counties.

The United Farm Workers’ contract with Gerawan was ordered by a mediator and approved by the farm labor board in 2013 — 23 years after the union won an election to represent the company’s workers. After that election, the two sides held only one negotiating session, in 1995, and did not meet again until 2012, after the union asked to reopen talks. The union requested mediation after further negotiations failed.

Union President Arturo Rodriguez said Monday that Gerawan owes the workers more than $10 million under the contract.

Gerawan countered that the farm labor board is violating its workers’ rights by refusing to count ballots from a November 2013 election on whether to decertify the union. The board held hearings and concluded the company had improperly interfered in the election by supporting and helping to fund the decertification campaign. Gerawan has challenged that ruling in a state appeals court in Fresno.

Monday’s ruling “creates the opportunity for new life” in the “moribund” farm labor law, said William Gould, a Stanford law professor and former chairman of both the state farm labor board and the National Labor Relations Board.

The case is Gerawan Farming vs. Agricultural Labor Relations Board, S227243.

Bob Egelko is a San Francisco Chronicle staff writer. Email: begelko@sfchronicle.com Twitter:@egelko