The court’s decision, which will affect people who have been detained in airports, came after the ACLU and other activist groups filed a class action lawsuit on behalf of two Iraqis who were held at John F. Kennedy International Airport in New York as a result of the order.