Daniel Rico was relaxing in his pajamas in a hotel room after a day biking through Peru’s Sacred Valley when his phone rang. The Peruvian president was about to make an announcement related to the coronavirus pandemic, his tour guide said. Rico went online and saw that Peru’s borders would close in roughly 24 hours.

Minutes later, the 33-year-old financial analyst from New Jersey and a handful of other foreigners were being driven hastily in the dark along winding Incan roads. But when Rico arrived at the Cusco airport at 2 a.m. Monday, he found thousands of other travelers clamoring to leave and no available tickets. Skirmishes broke out as people pushed to the front of the line, he said.

Rico and nine other Americans are now stuck in a hotel in downtown Cusco, where a 15-day quarantine is enforced by soldiers with face masks and rifles. A police officer recently shoved Rico against a wall, he said, and threatened to arrest him for going out to buy groceries.

“Things are getting bad here,” said Rico, whose wife is worriedly waiting for him at home. “Fly me to Texas or Louisiana. Drop me in Wyoming, and I’ll rent a car. But we need to get out of this country.”

From Cusco to Casablanca to Cape Town, thousands of Americans like Rico are currently stuck overseas as the rapidly expanding pandemic has caused a cascade of countries to close their borders.

As their money, medications and patience run out, Americans have watched in mounting frustration as other countries have quickly evacuated their citizens. Feeling abandoned by their government, thousands have turned to social media for help and solace, joining online groups with names like “Americans Stuck in Peru,” “American Citizens Stranded In Guatemala” and “Stay Strong, Quarantine On.”

Their sense of panic deepened on Thursday when the State Department announced American citizens overseas should return to the United States immediately “unless they are prepared to remain abroad for an indefinite period.”

The announcement, coupled with the initial lack of a plan to help Americans come home, has drawn criticism from lawmakers whose inboxes are filling with emails from furious constituents trapped overseas.

“This is a source of great frustration,” Sen. Chris Van Hollen (D-Md.) told The Washington Post. “This administration has made a mess of this by failing to take the necessary actions. We’ve been working for weeks to try to get these Americans who are stranded abroad a way to get home. We’ve watched as other countries have chartered airlines to get their citizens out.”

In a briefing Friday, Secretary of State Mike Pompeo again said Americans overseas should rely on “commercial departure options” whenever possible but also announced the creation of a “repatriation task force” to help U.S. citizens come home.

“We’re trying to get people back from these places where air travel has been disrupted, and we will get that done over time,” he said.

That announcement came the same day that the Air Force ferried 89 Americans — including the U.S. women’s football team — home from Honduras and a handful of chartered flights began arriving in the United States from Morocco and Peru.

The sudden closure of borders and cancellation of flights shocked many Americans overseas, even though some admitted that relatives — or their own common sense — had advised them against leaving the United States in the first place.

Rosalie Malsberger was barely two days into a scuba diving trip on the Honduran island of Roatan when a note was slipped under her hotel room door.

“Dear Guest,” it said in English and Spanish. “In an effort to prevent the spread of coronavirus our authorities have decided to close all ports of entry to the Bay Islands, starting Sunday [March] 15 at midnight for a period of 7 days.”

Malsberger and 15 others on the trip began contacting their elected representatives and U.S. officials. By Thursday, all they had received from the State Department was a generic response saying that “while the U.S. government has successfully evacuated hundreds of our citizens in previous crises, these flights do not reflect our standard practice and should not be relied upon” now.

The scuba divers each agreed to pay $1,000 to help hire a charter plane home. But the Honduran government refused to provide the plane a landing permit, Malsberger said. And when the group could not get anyone from the U.S. government to pressure the Hondurans, the flight fell through.

The standoff has shredded the 33-year-old’s nerves. Would her elderly parents be okay without her back in Boston, she wondered. Would the resort staff keep supplying them with food? And what would happen when her anti-malarials and anti-anxiety medication suddenly ran out?

“It’s the uncertainty that’s really scary,” she said. “I’m worried that things here are going to collapse very quickly.”

So, too, is Khadija Noakes. Last month, the 26-year-old traveled from Alexandria, Va., to Algeria to surprise her in-laws with a visit with their new grandson, 6-month-old Rayan. Noakes and the infant were only supposed to stay for a month.

But days ago, Algeria suspended all travel through Europe and Noakes’s flight, scheduled for Wednesday with a layover through Paris, was canceled, leaving Noakes unable to return home to her husband.

Noakes said she pleaded with officials at the U.S. Embassy in Algeria to help refer her to clinics for her infant son, who is due for his six-month vaccinations at the end of the month. “The clinics listed on your website will not administer them,” she wrote in an email. She now worries her son will be forced to spend several more months in Algeria, unvaccinated.

“Is this going to impact my son in the long run,” she wondered.

Each time she speaks to her husband via FaceTime, she can see how hard it is for him to miss such key moments in the life of their young son, their first and likely only child.

“The hardest part is just not being able to be a family. I know he doesn’t vocalize it but I can see,” she said, her voice breaking over the phone as she nursed her crying baby.

“When we came here, his son wasn’t sitting up,” she said. “Now his son is playing with a walker.”

Countless other moments were dashed — or at least delayed — as a globe accustomed to incessant international travel came screeching to a sudden halt, laid low by a virus too small for the eye to see.

Timothy Jones, 65, and his wife and elder daughter had planned on visiting Arequipa, Peru, on March 14 for the wedding of his younger daughter. But as fears of the coronavirus grew, his wife, Judy, whose lung was damaged during a recent heart surgery, decided to stay behind in Shrewsbury, Pa.

Hours after Jones and his daughter arrived in Arequipa without her, they heard a report over the radio in the groom’s van: Peruvian President Martín Vizcarra announced the borders would be closing. The wedding was called off, and the family scrambled to book the last flight out of Lima. But then the first leg of their flight was canceled due to heavy fog. Now Timothy Jones and his older daughter are expecting to be stuck in Peru for weeks.

Instead of celebrating his baby girl’s wedding, he now worries about his wife — alone and in danger of falling ill back in Pennsylvania. Even if they are reunited soon, there is the awful thought that he might bring her the virus from overseas.

“What happens once we get home,” he wondered, “if we can get home safely?”

Amid the uncertainty, Americans whose complaints to officials had been met with silence instead turned to one another for answers.

By Friday night, more than 2,000 people had added their names to a Google spreadsheet of American citizens stuck in Peru. The spreadsheet suggested tweeting at a list of celebrities ranging from the president to Pompeo to Ellen DeGeneres with the hashtag #stuckinperu.

The social media campaign appeared to have worked Friday when the U.S. government helped charter flights to evacuate hundreds of Americans from Peru, according to ABC.

That followed the evacuation Friday morning of hundreds of Americans from Morocco, where flights had been suspended on March 15.

By Friday afternoon, word of the evacuations had reached hundreds of Americans stuck in Guatemala, where flights had been suspended four days earlier.

Nearly 700 joined the “American Citizens Stranded In Guatemala” page on Facebook, where the posts were a mixture between anger and plots to escape. Some people wrote that they had hired a driver to take them to the border with Mexico, where they crossed on foot before hiring a car to Mexico City to catch a flight to the United States.

Helen Tolentino saw the posts and wondered what to do. The 23-year-old and her mother had been visiting Tolentino’s terminally ill grandmother in El Progreso, Guatemala, since March 9. When their flights were canceled, she bought new tickets three times, only for each to be called off. Some were going for nearly $3,000 each way, an impossible amount for the full-time student at Virginia Commonwealth University and her mother, a cook.

Tolentino needed to go home not only to study but also to earn money for tuition by waiting tables in Richmond.

The Facebook posts showed her how.

“I feel as if we’re doing more for our citizens than our actual government,” she said.

Late Friday night, Tolentino sent a WhatsApp message to a Post reporter saying she and her 57-year-old mother had decided to risk crossing into Mexico.

“We’ve been advised to travel at night as there is less chance of officials wanting bribes to allow us to leave,” she wrote. “We packed in less than 30 minutes. We are praying for a safe journey.”

Holed up inside the hotel Santa Maria in downtown Cusco, the 10 Americans wondered what hard decisions they would soon have to make. Each day left them feeling more abandoned, as hotel staff evaporated and guests from other countries evacuated.

Milo Andrus, 41, and his wife Hayley, 39, were ranchers from northeast Arizona whose first international vacation together had quickly gone haywire.

The couple had arranged their trip a year ago, leaving their five young girls with relatives and providing their 500 cows with food for a week. No sooner had they arrived in Cusco and gone to a souvenir shop than a tour guide told them they better turn around and leave before the border closed.

“It was too late,” Milo said. “Unless you had a flight the next day already, you were out of luck.”

The couple had booked new flights that had then been canceled, but they were now hopeful a departure in early April would stick. Or that the U.S. government would belatedly come to the rescue.

“We pride our freedom,” Hayley said. “I guess the United States is saying, ‘you got yourself there, now get yourself home.’ ”

Time was of the essence. They FaceTimed their daughters on Tuesday only to learn the littlest one was sick. The 2-year-old had a fever and sore throat, which a doctor had diagnosed by phone as strep throat but the couple feared could be coronavirus.

Then there was the ranch, where the cows needed to be moved to fresh pasture and the heifers were starting to calve.

Rico, who had gone from mountain biking to martial law in 72 hours, was eager to get home to his wife. Fluent in Spanish, he had taken it upon himself to buy food for the Americans. When police began demanding a permit to go the market, he convinced the hotel to print one listing him as an employee.

But then he was accosted by the police officer on Wednesday, he said. The next day, the police gave way to heavily armed soldiers, who strolled the cobblestone streets with loud speakers warning people to stay inside. At night, the soldiers enforce a strict curfew.

“Every day they are more aggressive,” he said. “Every day you see less food in the market and prices higher.”

As they waited, performing calisthenics on the roof to stay sane, the Americans heard Saturday morning that Peru would be halting all flights, even humanitarian evacuations, the following day.

“The help of our government might be too late,” Rico said in a text. “Please HELP US.”

Miriam Berger and John Hudson contributed to this report.