The high-wire decision follows a multi-week legal battle between the Trump administration and the chief judge on D.C.’s federal court.