The judge's ruling challenges one of the White House's most sweeping attempts to downsize the federal government.