ROME — Checkpoints block entry to a dozen towns across northern Italy. Milan's landmark cathedral and opera house lie empty. Venice's Carnival was ordered closed two days early. Schools are shuttered, soccer matches called off.

For much of the past month, the fight to contain the coronavirus has depended largely on China, whose authoritarian communist government has relied on high-tech surveillance and tight restrictions on the movements of hundreds of millions of people.

As the virus jumps to other parts of the world, the fight is entering a new phase, testing the extent to which democracies are able or willing to curtail freedoms and impose sustained restrictions of their own.

Italy, where confirmed cases jumped from a few to more than 200 in a matter of days and six people have died, has responded aggressively. Checkpoints outside hot-spot towns are allowing only those with special permission to enter or leave.

South Korea has avoided ­China-style bans on movement — asking, not ordering, residents of the hard-hit city of Daegu to stay indoors.

Hanging over such tactics is the question of how the people will respond if the measures persist for weeks or longer — particularly in Italy, where the fractious government is subject to constant second-guessing and the economy was teetering on recession before the virus erupted.

“I don’t think it is wise to stop the whole of Italy for two or three months and put the economy on its knees for a problem that is big but not so big,” said Andrea Braga, 55, who owns a bar in Casalpusterlengo, a sealed-off town outside Milan.

When the threat of the virus felt remote, democratic countries including the United States imposed controls on people returning from China. The city of Costa Mesa, Calif., won a court injunction last week blocking the transfer of up to 50 people in federal quarantine to a complex the city said was unsuitable for them.

Italy went a step further, banning flights to and from China. Now that the virus has gained a foothold in Europe, the focus has turned to the normally permeable borders within the continent, and authorities across the bloc are scrambling to prepare.

If the virus expands across Italy, neighboring governments could face public pressure to back away from the continent’s open-border ideals in the name of security. European officials in Brussels on Monday emphasized there was no plan to close borders.

The coronavirus could pop up elsewhere as it did in Italy: ­without much warning. Some infectious-disease analysts have speculated the virus was in Italy for weeks, carried by one or more people with negligible symptoms, before it was detected.

German officials said this month they had contained a cluster of cases. Health Minister Jens Spahn said Monday that the country is bracing for more infections. The coronavirus has “arrived as an epidemic in Europe,” Spahn said. “So we must expect it to spread to Germany.”

He said developments in Italy, where the chain of infection could no longer be traced, had changed his ministry’s assessments.

Germany, has recorded 16 coronavirus infections, 14 of them linked to employees of a car parts manufacturer in the southern region of Bavaria. No new infections have been detected for more than two weeks.

Lothar Wieler, president of Germany’s governmental agency responsible for disease control, said he expected the virus to spread.

“When it comes to Germany, it will not go through Germany like a hurricane within two weeks,” he said. “It will hit different regions in succession.”

In Italy, the outbreak has come into view in a matter of days, with case numbers spiking almost hourly and the virus jumping from one northern region to the next. Most of the cases have been contained in Lombardy, in towns to the south of Milan, the country’s economic hub. The neighboring region of Veneto has a smaller cluster.

Officials have described closing towns as a short-term “sacrifice.” In a briefing Monday, Angelo Borrelli, Italy’s head of civil protection, referenced the trope that Italians can be “undisciplined” but said they can be “very orderly” for the sake of a health crisis.

Italians trapped in the hot spots have voiced little opposition. Videos from inside those towns show largely deserted town centers, except for the occasional person walking a dog or venturing to a mini-market for groceries. One church, where a funeral was scheduled, allowed only family members inside.

“The atmosphere is pretty eerie,” said Fabrizio Senneca, a church employee in Codogno. “We are trying not to let psychosis take hold. I have very little to do.”

It was a sense of foreboding that made people willing to hunker down. Authorities say cases have popped up with no obvious connection to travelers from China or people already infected.

“As always in Italy, individual behaviors are hard to govern,” said Giovanni Orsina, the director of the school of government at Luiss Guido Carli University in Rome. “But it feels to me like there is a willingness to compromise on freedom in the name of protection.”

Countries neighboring China have faced their own questions about how to safeguard themselves.

Japan is still debating the confinement of more than 3,700 people on board a cruise ship for two weeks in an attempt to contain the spread of the virus.

It was an attempt that critics say was unsuccessful — more than 700 people on the Diamond Princess ended up becoming infected — and unnecessary: The virus was already spreading in Japan.

It was also dangerous because it risked the lives of the many hundreds of elderly passengers. Critics say it was also morally questionable because crew members’ lives were put at risk by forcing them to continue working without isolation from each other.

Three passengers in their 80s have died, and at least 129 crew members have contracted the virus.

“Quarantine means, in other words, restrictions of human rights for some period — in this case, 14 days,” said Norio ­Ohmagari, head of the National Center for Global Health and Medicine’s Disease Control and Prevention Center in Japan and a government adviser on the crisis. “I’m sure not all the Japanese people or the international community will agree with that, in terms of the consideration of human rights and human dignity.”

Shigeru Omi, head of the Japan Community Health-care Organization and a senior government adviser on the crisis, said officials were “of course” sympathetic to the human rights of the crew. But he said they had to remain on board to serve the passengers.

Human rights also played a part in the decision to allow Japanese passengers to return home after their 14-day quarantine, Omi said.

While the United States and other countries have imposed an additional 14-day quarantine on people evacuated from the ship, Japan allowed its passengers to return to their homes if they tested negative for the virus. Authorities asked them not to leave their homes “unless absolutely necessary” and to wear masks if going out.

“We strike the balance: On the one hand, we have to respect the human right of the movement of people, et cetera,” Omi said. “But also, we have to give focus to the public interest.”

Loveday Morris and Luisa Beck in Berlin and Steve Hendrix in Jerusalem contributed to this report.