The decision is a setback for the president’s efforts to wield the criminal justice system against his perceived enemies.