A federal judge in Brooklyn, N.Y., ordered the U.S. government on Saturday to stop the removal of refugees and immigrants who had been detained at airports across the country—blocking the enforcement of parts of an executive order issued by President Donald Trump Friday.

The judge’s order pertains to refugees, visa holders and other individuals from Iraq, Syria, Iran, Sudan, Libya, Somalia and Yemen who had been legally authorized to enter the U.S., but were detained as they came into the U.S. Saturday. The president’s executive...