President Trump’s latest effort to curb immigration into the U.S. hit a legal obstacle just as thousands of migrants who traveled in caravans from Central America amass along the southern border.

U.S. District Court Judge Jon Tigar late Monday put a restraining order on a Nov. 9 presidential proclamation that made immigrants who cross the border illegally ineligible to apply for asylum and said such a change would require legislative action.

The...