At a sweltering refugee camp on the Kenya-Somalia border, dozens of Somalis who had cleared all the final security and medical checks to enter the United States were told to prepare themselves for a flight to a new life.

In Pittsburgh, a medical student from Iran finally got back to school after a chaotic journey that left him sleeping on a chair for four days.

Inside Terminal 4 at Kennedy Airport, a 6-year-old boy sprinted across the arrivals hall to embrace a family friend who had finally made it back to the United States after being marooned for a week in his home country, Sudan.

With the door open again for travelers and refugees who had been excluded by President Trump’s order on immigration, the race to reach the United States accelerated on Sunday among waves of people fearing the opportunity might be fleeting.

The rush inundated some domestic and international airports, reunited loved ones and friends and prompted another round of criticism from Mr. Trump that national security was being endangered by court orders that blocked his tight border policy from taking effect. Mr. Trump and his aides have suggested that terrorists and others who wish to do harm to the United States could arrive through normal immigration channels and that the administration needs time to tighten its vetting procedures.

Those travelers now being admitted to the United States from seven predominantly Muslim nations singled out for a temporary ban by Mr. Trump had already been granted visas after screening. Refugees from those countries and elsewhere who were rushing to reach the United States had likewise already been vetted, even more extensively, in a process that involves dozens of checks and can take more than two years.

But it was unclear whether a court order blocking Mr. Trump’s policy from taking effect, issued by a federal judge in Seattle, would remain in place for long, creating a sense of urgency among those trying to reach the United States.

The back and forth had sown confusion, anxiety, fear and disbelief, but the court order created “a temporary window that we wish to take advantage of,” said Leonard Doyle, a spokesman for the International Organization for Migration, an intergovernmental agency that facilitates refugee resettlement. “Our staff are being told to move like crazy.”

Families and immigration advocacy groups were buoyed twice over the weekend — first when the Seattle judge temporarily blocked the executive order, and again when the United States Court of Appeals for the Ninth Circuit in San Francisco denied the government’s attempt to gain an emergency stay. But a mood of uncertainty persisted after a week in which thousands of travelers bound for the United States were halted in transit and turned away at airports, and courts across the country issued conflicting rulings over whether and how the executive order should be carried out.

Mr. Trump reacted angrily on Sunday. In a Twitter post, he seemed to give immigration lawyers and advocates reason to fear that the country may not remain open for long to refugees, or to visa holders from the seven nations — Iran, Iraq, Libya, Somalia, Sudan, Syria and Yemen.

“I have instructed Homeland Security to check people coming into our country VERY CAREFULLY. The courts are making the job very difficult!” he wrote.

Mr. Doyle said that between Monday and Feb. 17, about 2,000 refugees would be rebooked on flights to the United States. Those who were expected to leave first had moved out of their apartments or refugee camps, sold their belongings and turned in their food ration cards.

In Kenya, dozens of Somalis who had cleared all the final security and medical checks to enter the United States were waiting on Sunday in the refugee camp, where they were told that they might be able to travel in the next few days. But they were no longer sure who — or what — to believe.

“I feel completely ruined,” said Ahmed Hassan, a Somali refugee heading for Rhode Island. In the past few weeks, Mr. Hassan was bused out of the camp; sent to a transit center in Nairobi, Kenya’s capital, several hundred miles away; given travel documents; told he was about to fly to America; told he was not about to fly to America; bused back to the camp; and then told he might actually fly to America after all. He boarded a bus in Nairobi to return to the camp just hours before the federal judge lifted the travel ban.

Mr. Hassan had sold his home and feared that he could be targeted as an American sympathizer by the Islamist and anti-American militants who were known to move in and out of the camps. He had arrived back at the refugee camp on Saturday afternoon, retreated from the crowds shouting questions at him and hid inside a room.

On the floor of Terminal 4 at Kennedy Airport, Wael Izzeldin, 6, clutched a green marker as he wrote a welcome sign for his father’s best friend, Dr. Kamal Fadlalla. Dr. Fadlalla is a second-year resident at Interfaith Medical Center in Bedford-Stuyvesant, Brooklyn, and had been on vacation visiting his mother in Sudan, his first time home in three years.

When Dr. Fadlalla appeared, the boy went running across the arrivals hall, leapt and wrapped himself around the doctor, crushing the tiny sign.

Dr. Fadlalla was ebullient but fatigued. Though he holds a visa for people in specialty professions, he had been turned away at the airport, and spent a week marooned in Sudan. Around him, members of his union, Committee of Interns and Residents, wearing white lab coats, cheered.

“I’m glad justice won,” he said, adding that he was happy to return to his family and patients. “I need to get back to my work.”

Across the country on Sunday, the nongovernmental agencies that place refugees into homes and help them find jobs were gearing up to resettle as many as possible, while recovering from the whiplash of last week. Before Friday, their work had begun to trickle off, as they could resettle only refugees who were already in transit when the president’s order was signed. They had been preparing for their activities to come to a halt for four months in accordance with the order.

Leslie Aizenman, of Jewish Family and Children’s Services, a resettlement agency in Pittsburgh, had already put back on the market an apartment for a family from Homs, Syria, who had been scheduled to arrive in the United States on Tuesday. Their trip was canceled by the State Department last week, and Ms. Aizenman was unsure when it would be rescheduled.

Her staff had already returned the backpacks filled with school supplies and stuffed animals they had prepared for the family’s 9-year-old son and 8-year-old daughter. They had also told another Syrian family in Pittsburgh, who had volunteered to make a warm meal to welcome their new neighbors, not to bother.

Because of the last-minute change, Ms. Aizenman said that the refugee family may have to live in temporary housing, and settle for a restaurant meal rather than something homemade.

“We had stopped the process, but no matter what, we’ll accommodate them when they get here,” she said.

An interim ruling on whether the executive order may be enforced is likely to come quickly from the appeals court. But the ultimate decision on whether the order is lawful will take much longer, and is likely to come from the Supreme Court. That means people seeking to travel or settle here may be in limbo until the case is finally resolved. Over the weekend, lawyers were telling clients to take advantage of the precarious window.

“We are encouraging people to come in as soon as possible,” said Mary McCarthy, executive director of the National Immigrant Justice Center, a Chicago-based organization that provides legal services and advocacy to immigrants. “If you need to be back in this country, you should do it now.”

Ms. McCarthy said her organization had been in regular contact throughout the weekend with a network of roughly 1,500 lawyers who had volunteered to help travelers pro bono. The lawyers were stationed in shifts in airports across the country, observing customs officials to ensure that the Seattle judge’s ruling was being carried out, and counseling refugees and visa holders on how to prepare for issues that could arise with their immigration status.

“We are being very vigilant,” she said.