A federal judge on Monday directed federal and state officials to answer the questions of Costa Mesa, Calif., residents about their plans to bring Americans who have tested positive for the coronavirus but show no signs of illness to a closed ­mental-health facility in the city.

District Judge Josephine Staton cautioned that the city — and Orange County if it joins the effort — does not have veto power over state and federal quarantine decisions and faces an uphill battle trying to block the transfer of people from Travis Air Force Base in Northern California.

She said she would not make a decision in the city’s lawsuit based on people’s fears, but was also critical of state and federal officials for not doing more to allay people’s concerns. She urged them to answer residents’ questions about who would care for people who tested positive or were potentially exposed to the virus, how many quarantined individuals might be moved to Costa Mesa and what would happen if they developed symptoms and required hospitalization.

“When decisions are made in a hurry, mistakes are made,” she said, summoning the parties back to her courtroom on March 2 for a ruling.

Costa Mesa and Anniston, Ala., are the first U.S. communities that have sought to block plans to transfer Americans repatriated from Asia and now in federal quarantine to facilities in their midst. While Costa Mesa won a preliminary injunction Friday to temporarily block the transfer, top-ranking Alabama officials — including Gov. Kay Ivey (R), U.S. Rep. Mike D. Rogers (R) and U.S. Sen. Richard C. Shelby (R) — took their case directly to President Trump and apparently won an assurance that the administration would not move forward with its plans there.

The efforts by the two communities reflect growing anxiety about the risks of the coronavirus outbreak for communities in the United States, and suggest that federal officials may have difficulty housing quarantined people as the number of confirmed cases in the nation has grown to more than 50.

The count jumped after the State Department and a top health official overruled the Centers for Disease Control and Prevention and brought back more than 300 passengers from the Diamond Princess cruise ship in Japan, including 14 who had tested positive for the virus. Passengers on that ship are at high risk of contracting the virus because of their exposure in a confined space to those who may have been infected.

Officials in both Costa Mesa and Anniston have expressed compassion for people exposed to the virus, but argued that housing them in facilities in residential communities could pose risks to residents. Mary Cahill, a retired teacher and resident of Santa Ana, which neighbors Costa Mesa, said that “compassion does not equal negligence.”

Jennifer Keller, a lawyer for Costa Mesa, spoke to the fears of many in the audience at the court hearing when she said, “So little is known about this illness.” Keller reminded the judge that tourism in Orange County, home of Disneyland, is “massive” and that a coronavirus outbreak could devastate the economy.

Local officials also said they did not receive clear communication from the federal government that their facilities could be used to aid in the response.

“We felt blindsided,” Andrea Marr, a member of the Costa Mesa City Council, said in an interview. “People have an expectation that they at least get some answers, that they know what the plan is.”

Costa Mesa argued in its lawsuit that federal and state authorities did not coordinate with local officials before deciding they would transfer people who had tested positive for the virus to the Fairview Developmental Center, which they described as a “dilapidated” complex unable to handle infectious-disease patients.

City officials also said they received conflicting information from state health officials about the medical status of the people in question, the amount of time they would need to be quarantined and how various scenarios would be handled.

In its response to the lawsuit, the state of California said that it was “frivolous” and that the state’s quarantine laws enabled it to identify state properties that could house quarantined residents.

Legal experts said it was unlikely that Costa Mesa’s lawsuit would succeed because cities typically cannot override the decisions of a state government.

“The question in the court is, can a city object to what a state government does?” said Polly Price, professor of law and global health at Emory University. “Federal courts are pretty clear you can’t sue a state government in court. There isn’t really a federal order to challenge here because the key fact was that California’s state public health department . . . they’re in complete control.”

In its response to Costa Mesa’s lawsuit, the federal government argued that it was based on “speculation and unfounded internet fear — not science, facts, or accepted health practice.”

“Time is of the essence in this response to the public health emergency presented by COVID-19: this public health response requires action in hours and days, not days and weeks,” the government wrote. “Any act that hinders the ability of federal and state public health authorities to implement these effective, time-tested measures endangers the public health — and, thus, the safety and well-being of the American people.”

Yet local Costa Mesa officials and residents argued that the Fairview Developmental Center was in the middle of residential neighborhoods, and that children often use its fields for soccer practices, games and other events.

Haverly Horton, a city resident whose 10-year-old son has a primary immunodeficiency, said she worries that Fairview is not a secure facility and that the virus could easily spread to vulnerable people like her son.

“I’d love for them to show us a plan and how they’re going to enforce it,” Horton said. “I don’t want to be a NIMBY, but I don’t want to be someone who’s super liberal and say let’s bring everybody in here and then my own son dies because I’m foolish.”

Rowe reported from Santa Ana. Abutaleb reported from Washington.