Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

SEATTLE — A federal appeals court on Thursday rejected the Trump administration's limited view of who is allowed into the United States under the president's travel ban, saying grandparents, cousins and similarly close relations of people in the U.S. should not be prevented from coming to the country.

The unanimous ruling from three judges on the San Francisco-based 9th U.S. Circuit Court of Appeals also cleared the way for refugees accepted by a resettlement agency to travel here. The decision upheld a ruling by a federal judge in Hawaii who found the administration's view too strict.

"Stated simply, the government does not offer a persuasive explanation for why a mother-in-law is clearly a bona fide relationship, in the Supreme Court's prior reasoning, but a grandparent, grandchild, aunt, uncle, niece, nephew, or cousin is not," the 9th Circuit said.

Related: Halfway Through, Trump Coming Up Empty on Travel Ban

The appeals panel wrote that under typical court rules, its ruling would not take effect for at least 52 days. But in this instance, the judges said, many refugees would be "gravely imperiled" by such a delay, so the decision will take effect in five days.

"Refugees' lives remain in vulnerable limbo during the pendency of the Supreme Court's stay," they wrote. "Refugees have only a narrow window of time to complete their travel, as certain security and medical checks expire and must then be reinitiated."

The Justice Department said it would appeal.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

"The Supreme Court has stepped in to correct these lower courts before, and we will now return to the Supreme Court to vindicate the executive branch's duty to protect the nation," the agency said in a statement.

The U.S. Supreme Court said in June that President Donald Trump's 90-day ban on visitors from Iran, Libya, Somalia, Sudan, Syria and Yemen can be enforced pending arguments scheduled for October, partially overturning lower-court rulings. But the justices said it should not apply to visitors who have a "bona fide relationship" with people or organizations in the U.S., such as close family ties or a job offer.

That set the stage for much disagreement over what constitutes a bona fide relationship.

The government interpreted such family relations to include immediate family members and in-laws, but not grandparents, cousins, aunts and uncles. The judge in Hawaii overruled that interpretation, expanding the definition of who can enter the country to the other categories of relatives.

He also overruled the government's assertion that refugees from those countries should be banned even if a resettlement agency in the U.S. had agreed to take them in.

The administration argued that resettlement agencies have a relationship with the government, not with individual refugees. The appeals court rejected that, saying the Supreme Court was concerned with any harm the travel ban might impose on people or organizations in the U.S.

Resettlement agencies have spent time and money securing rental housing, buying furniture and performing other tasks that would be in vain if the refugees were blocked, the 9th Circuit said. They also would lose out on government funding for the resettlement services.

Related: U.S. Settles Suit Over Trump's First Travel Ban

Lawyers for the government and the state of Hawaii, which challenged the travel ban, argued the case in Seattle last week.

Deputy assistant attorney general Hashim Mooppan ran into tough questions as soon as he began arguing the government's case, with Judge Ronald Gould asking him from "what universe" the administration took its position that grandparents don't constitute a close family relationship.

Mooppan conceded that people can have a profound connection to their grandparents and other extended relatives, but from a legal perspective, the administration had to draw the line somewhere to have a workable ban based largely on definitions used in other aspects of immigration law, he said.

Hawaii is also one of 15 states that sued the Trump administration Wednesday over its plans to end the Deferred Action for Childhood Arrivals program that protects young immigrants from deportation.

"Today's decision by the 9th Circuit keeps families together. It gives vetted refugees a second chance," state Attorney General Douglas Chin said in a statement. "The Trump administration keeps taking actions with no legal basis. We will keep fighting back."