The ruling dealt a setback to Gov. Jan Brewer, one of a few Republican governors who sought to expand benefits at the state level.