The US President's ambitious plans have suffered a major setback after a federal judge intervened.