After a slow start to a rapidly spreading pandemic, U.S. embassies and consulates around the world are diverting most of their resources to the task of evacuating U.S. citizens.

In Ecuador, the U.S. consul general and ambassador have gone to the airport in the middle of the night to smooth hitches for jittery Americans departing on chartered flights. The U.S. Embassy staff in Morocco has handled baggage check-ins for airlifts of American tourists.

Consular officers in Peru are converting a hangar used by U.S. narcotics control officers into a processing center for evacuation flights. And in Brazil, where 9 in 10 embassy employees are teleworking, consular officers in the port city of Recife got more than 100 vacationing Americans off a “sick” cruise ship with two infected passengers and put them on a bus to the airport.

Similar scenes are underway at many other diplomatic missions, with the entire world under a State Department do-not-travel advisory.

The suddenness with which some countries sealed their borders and suspended international flights amplified an unprecedented challenge for the State Department. Its routine crisis-response exercises for natural disasters and civil unrest typically envisioned getting Americans and diplomats to safety in nearby countries. In a world swept by the coronavirus, nowhere is entirely safe.

As lawmakers and marooned travelers complained that the State Department wasn’t doing enough to get people home quickly, diplomats were enlisted for tasks normally handled by commercial airlines. Bilateral negotiations focus on ways to maneuver around local rules and regulations to allow empty aircraft to fly rescue missions into countries and depart with stressed-out travelers.

“It’s never been on a global scale like this,” a diplomat in Ecuador, a veteran of 17 years in the Foreign Service, said after apologizing for sounding groggy after sleeping only four hours the previous night. “This requires a lot of creativity, talking with the department, outreach to American citizens.”

The State Department is scrambling to catch up. In January, it took several days to arrange the evacuation of 800 Americans. Every day now, thousands of Americans board chartered aircraft arranged by U.S. diplomats. Since January, more than 10,000 Americans have been evacuated. At least 66 more flights are scheduled in coming days.

Another 50,000 Americans have notified U.S. embassies they need help. Ian G. Brownlee, the principal deputy chief of consular affairs, conceded that the State Department’s capacity is “strained.”

In some countries, large numbers of Americans are clamoring for assistance. Honduras, Ecuador and Peru, for example, each has thousands of U.S. citizens seeking to get on flights.

Though more than 1,000 Americans have left Peru, the chargé d’affaires, Denison K. Offutt, took to Twitter this week pleading for patience.

“We are in this together, and together we will all get through this,” he said in a video posted as the State Department dispatched a team of consular officers and a senior official from the Bureau of Western Hemisphere Affairs to oversee the evacuation in Lima.

In Ecuador alone, 8,000 U.S. citizens have expressed an interest in being evacuated. About 120,000 Americans are in the country, the vast majority retirees residing there.

The logistics can be complex. Diplomats must line up approvals from airports, the airlines and police. But passengers have to get to the airport on their own before curfew falls, passing through as many as 15 checkpoints.

A diplomat posted in Ecuador said in a telephone interview that the consular officials from the embassy in Quito and the consulate in Guayaquil have seen off every flight since the first one March 19. The staffers wear crisis-response vests emblazoned with the American flag and the words “U.S. Embassy.”

“I can’t guarantee we will see every outbound flight, but we’ll try to do so,” said the official, speaking on the condition of anonymity because he, like others, wasn’t authorized to speak publicly about logistics. “My concern is, as the pandemic spreads, more people will want assistance. But we’re here for every single person who wants us.”

Some of the backlogs have cleared up since travelers began making frantic calls to their families, members of Congress and news outlets.

After the Moroccan government stopped all international flights March 15, U.S. consular officers fielded 3,000 emails and hundreds of phone calls in the first few days. Getting them out became what diplomats call a “whole of mission” operation.

But no U.S. carrier flies directly to Morocco. Air France would take only passengers who could book a connecting flight to the United States. British Airways had seats, but it flew only into Marrakesh. More than 1,000 Americans left on several flights departing March 20 and March 21.

Arthur Goldberg was aboard one. The retired Justice Department lawyer and his wife were in the middle of a 17-day tour of Morocco, out in the desert, when their tour operator told them they had to leave. Goldberg, who lives in Washington, said they were asleep at a hotel in Casablanca when an embassy email arrived advising them of a British Airways flight to London that afternoon — from Marrakesh. They made it.

“We were met by a host of consulate staff there,” said Goldberg, whose tour operator paid for a hotel and meals during a London layover. “They were very nice, welcoming and competent.”

Even as the State Department scurries to evacuate more Americans before the flights stop, one group is effectively stuck in place — the diplomats themselves.

Some have already left under the liberalized departure rules. This week the State Department sent a cable saying staff infected with the coronavirus may be able to take one of eight planes positioned to deploy within 24 hours. So far, the State Department has identified about five dozen employees posted overseas who have tested positive for the coronavirus.

The diplomats who remain are, like their counterparts in Washington, largely working from home — and worried about the pandemic’s spread

“They’re nervous,” said a longtime diplomat, speaking on the condition of anonymity to discuss internal concerns. “They’re stuck. If they want to leave, the time has passed or almost passed. Many of them are in places without solid medical care.”

The diplomat said senior State Department officials have not addressed what embassy staff should do, beyond teleworking and social distancing to minimize their chances of getting sick.

Several diplomats in countries where U.S. evacuations are underway said their focus has been on the task at hand. They described the work they are undertaking as a source of pride.

“It’s a great honor to serve the American public and help them,” said Alexander P. Delorey, the consul general in Quito, Ecuador. “We are working around the clock, worldwide, to help citizens who want to return home. We’re committed. It’s what we do.”