LOS ANGELES — A federal judge has dealt another blow to President Trump’s executive order barring some foreigners from coming into the United States, in a ruling that added to the confusion over the legality of the immigration measure.

Using more sweeping language than previous court rulings, Judge André Birotte Jr. of United States District Court here issued a temporary restraining order on Tuesday evening requiring the government to allow in people with valid immigrant visas from the seven majority-Muslim countries Mr. Trump sought to block.

The judge’s order affects only people who are seeking to live in the United States permanently and are taking the first steps to becoming a legal resident. This does not include tourists or students trying to enter the country.