LOS ALTOS, Calif. — A federal judge in Hawaii ruled late Thursday that the Trump administration’s temporary ban on travelers from six predominantly Muslim countries and on refugees should not prevent grandparents and other close relatives of residents from entering the United States.

The judge, Derrick K. Watson of Federal District Court in Honolulu, also declared that refugees with ties to a resettlement agency that was committed to receiving them had a relationship that made them eligible to enter the country.

If it stands, the decision could open the gates for thousands of refugees who have been cleared to enter the United States but who lacked the close relationships as defined by the Trump administration. Opponents of the ban cheered the ruling, while Attorney General Jeff Sessions sharply criticized it and said on Friday he would appeal it directly to the United States Supreme Court.

Last month, the Supreme Court ruled that a scaled-back version of the travel ban could proceed. Applicants who could show a “bona fide relationship” with a “person or entity” in the United States would be exempt from the 90-day ban on travelers from Iran, Libya, Somalia, Sudan, Syria and Yemen and the 120-day ban on refugees from around the world. The decision was a partial reversal of an earlier ruling by Judge Watson that had blocked the ban from taking effect.