MIAMI — The Federal Emergency Management Agency must continue to pay for temporary housing for Puerto Ricans displaced by Hurricane Maria for another 20 days, a federal judge ordered on Tuesday, another short reprieve for hundreds of families who have been unable to return to their homes.

The decision by Judge Timothy S. Hillman of United States District Court for the District of Massachusetts will allow Puerto Rican evacuees benefiting from FEMA’s temporary sheltering assistance program to remain in their government-paid hotel and motel rooms until checkout time on July 24 as the court holds further hearings to determine whether an additional extension is warranted.

[Read about Puerto Rican evacuees living in moving-day limbo.]

The aid was supposed to end at midnight on Saturday, but it was extended until midnight on July 4 after a civil-rights advocacy group filed a class-action lawsuit arguing that withdrawing the assistance would put some Puerto Ricans at risk of homelessness. About 950 families on the mainland and the island were still receiving the aid as of Tuesday, according to FEMA.

That number is significantly smaller than the more than 1,700 families who were receiving aid under the program on Friday. They have been spread across more than 30 states, the biggest number in Florida, with a number of others in Puerto Rico, Massachusetts and New York.