ROME — Government officials scrambled on Sunday to contain the first major outbreak of the coronavirus in Europe, locking down at least 10 towns near Milan, closing schools and canceling the iconic Venice carnival, as nearly 150 cases were announced in recent days.

The new cases are mostly in the Lombardy region, which includes Milan, and is one of Italy’s most densely populated areas. The spike — from fewer than five known cases before Thursday — has quickly made the country the biggest test of whether the virus can be successfully contained in an open European society.

The coronavirus crisis began in China in late December, and since then, more than 2,000 people have died worldwide, with most of the cases and fatalities in China. The country’s authoritarian government has taken extraordinary quarantine measures and imposed stiff restrictions on travel, but has still struggled to contain the virus.

In Asia, outside China, the hardest hit country has been South Korea, where there have been 602 confirmed infections and six deaths. On Sunday, President Moon Jae-in put the country on the highest possible alert, empowering the government to lock down cities and take other sweeping measures to contain the outbreak.

“The coming few days will be a critical time for us,” he said at an emergency meeting of government officials.

The same challenge now looms for Italy, Europe’s fourth-largest economy, where the government, a wobbly, and often bickering, coalition between the Democratic Party and the 5-Star Movement, has been in disarray for months.

The 5-Star Movement has often muddied the waters on important health issues, like vaccinations, by embracing conspiracy theories and playing on voter distrust of government. Whether the government can coalesce and snap in place preventive measures to stem the further spread of the virus will be one of the biggest crises it has faced.

The government response has been aggressive so far, led by the health minister, Roberto Speranza.

Regional and municipal authorities throughout Italy enacted a series of restrictive ordinances after the government issued emergency measures late Saturday. All public events in the Lombardy region have been canceled, whether “cultural, leisure, religious or sporting,” according to an ordinance issued by Attilio Fontana, president of the Lombardy region, drafted with the health ministry. Museums have been ordered to shut their doors.

Many other venues in Lombardy, aside from those providing essential services, have been closed, including most bars, nightclubs and movie theaters, as well as churches. In some other regions, similar closings took place.

“We invite people to stay at home, to try and contain this phenomenon that we still don’t know, except that it isn’t aggressive but moves quickly,” Giulio Gallera, the official responsible for health for the Lombardy region, said during a televised news conference Sunday.

In Lombardy, 10 towns were locked down after a cluster of cases emerged in the town of Codogno, about 60 km southeast of Milan. At least 50,000 people are affected by the lockdown. Residents were supposed to leave or arrive only with special permission.

On Sunday, police and armed forces personnel were deployed to monitor the entrances to the towns.

“Maximum precaution has been taken to protect citizens,” Prime Minister Giuseppe Conte of Italy wrote on Twitter Sunday.

Two military structures in Lombardy were being prepared to become isolation camps, while other military sites and hotels have been identified throughout the country. A military base in Rome has been housing evacuees from Wuhan, China, where the virus began, and the Italian passengers of the Diamond Princess, the cruise ship that has been under quarantine in Yokohama, Japan.

The outbreak in Codogno began after a 38-year old man known as “patient one” was admitted and diagnosed with the virus to the city’s hospital on Thursday. But the man had developed symptoms perhaps five days before that, potentially allowing the virus to spread.

Even more disconcerting is that health officials still don’t know how he contracted the virus because he had not been to China. But many cases in Lombardy, officials say, may be traceable to that one case.

At least five members of the hospital medical staff in Codogno and several patients have been infected. Other persons who tested positive include the man’s pregnant wife, a close friend and others who spent time with them. The towns surrounding the ones where the man works and lives have been included in the shutdown.

Similar lockdown procedures will be applied if new clusters emerge anywhere in Italy, officials said. According to the government decree, local officials are obliged to “take all appropriate containment measures” in the case that someone has tested positive for the virus and the source of the contagion is unknown.

Quarantine measures will also be applied to anyone who has close contact with someone who has the virus.

Gallera, the health official for Lombardy, said hospitals were increasing intensive care facilities, and hotels and other structures were being identified as possible venues to isolate people with the virus.

“We are acting preemptively” to avoid managing a bigger emergency, he said.