SAN FRANCISCO — Retired judges can take jobs in the public sector even if their judicial terms still have time to run, the California Court of Appeal ruled Friday.

The decision hands a win to Justice Arthur Gilbert and the California Judges Association. Gilbert brought a legal challenge in 2012, saying he may wish to retire and seek other public-sector employment before his 12-year term concludes in 2019.