The order, by US District Judge Derrick Watson in Honolulu, dealt a fresh courtroom defeat for Trump as the Republican president seeks to toughen US immigration policy.
The state of Hawaii had asked Watson to narrowly interpret a US Supreme Court ruling that revived parts of Trump's March 6 executive order banning people from the six countries for 90 days.
Watson yesterday declined to put on hold his ruling exempting grandparents and other relatives from the ban.
Watson harshly criticized the government's definition of close family relations as "the antithesis of common sense," in his ruling.
"Common sense, for instance, dictates that close family members be defined to include grandparents. Indeed, grandparents are the epitome of close family members," he wrote.
A Justice Department spokeswoman declined to comment. Neal Katyal, an attorney for the state of Hawaii, called the ruling a "sweeping victory" on social network Twitter.
The US Supreme Court last month let the ban on travel from the six countries go forward with a limited scope, saying it could not apply to anyone with a credible "bona fide relationship" with a US person or entity.
The Trump administration also said that all refugees without a close family tie would be blocked from the country for four months.
Trump said the measure was necessary to prevent attacks. However, the state of Hawaii sued to stop it, disputing its security rationale and saying it discriminated against Muslims.
Hawaii's attorney general Douglas Chin asked Watson to issue an injunction allowing grandparents and other family members to travel to the United States. Hawaii and refugee groups argue that resettlement agencies have a "bona fide" relationship with the refugees they help, sometimes over the course of years.
The Justice Department said its rules were properly grounded in immigration law.
The roll-out of the narrowed version of the ban was more subdued than in January, when Trump first signed a more expansive version of the order. That sparked protests and chaos at airports around the country and the world.
(Reporting by Dan Levine in San Francisco; Additional reporting by Andrew Chung in New York; Editing by Clarence Fernandez)