The ban, which Mr. Trump said was necessary to protect against "foreign terrorists", was reminiscent of a similar move he implemented during his first term in office from 2017 to 2021, when he barred travellers from seven Muslim-majority nations.