MILAN—Italy placed its entire national territory under quarantine, only two days after it locked down much of the country’s north, marking the most dramatic step by any country so far to contain the coronavirus epidemic.

Facing the biggest outbreak of the virus outside China, Italian Prime Minister Giuseppe Conte said all of the quarantine measures imposed in the north of Italy in recent days will apply to the whole country, with effect from Tuesday morning.

That means Italian authorities will allow travel to, from and within Italy only if it is demonstrably necessary for work or health reasons. The nationwide quarantine also means employees are urged to take vacation and stay home, bars and restaurants must close at 6 p.m., and virtually all public gatherings are banned. In shops, churches and all public places, people must keep a distance between themselves of a meter, or just over 3 feet.

The nationwide restrictions have no precedent in Italy since World War II. In recent history, no European democracy has experienced such sweeping restrictions on movement and public gatherings in peacetime, even during previous emergencies such as oil crises or urban terrorism.

“I decided to adopt even stronger, stricter measures to be able to contain the spread of the virus as much as possible,” Mr. Conte said at a news conference. “I’m aware of how serious this is, but I am forced to intervene even more decisively to protect all of us, and especially those who are more weak and vulnerable.”