Around the world, as a consensus has formed around the need for quarantine and social distancing to fight the coronavirus, a more delicate question has emerged: How do you enforce those new rules?

In every region, under all kinds of political systems, governments are turning to increasingly stringent measures — and deploying their armed forces to back them up.

Countries as varied as China, Jordan, El Salvador and Italy have sent service members into the streets. Guatemala has detained more than 1,000 people. In Peru, those who flout government restrictions can be jailed for up to three years. In Saudi Arabia, it’s five.

At no time since World War II have so many nations wrestled with what it means to be in a state of emergency and how to impose fundamental and sudden changes in human behavior.

Deploying troops is a startling but often effective way to keep people indoors, but its impact could ripple well beyond the end of the coronavirus, as countries decide when — and if — to cede the powers endowed by a global pandemic.

In Lebanon, Chile and Hong Kong, beset for months by protests, fear of the coronavirus has allowed the state to ban public gatherings without overtly violating civil liberties. In several countries, leaders have used the public health crisis to suppress freedom of speech and other constitutional protections.

“It’s really easy to ratchet up these kinds of powers and really hard to ratchet them back down,” said Juliette Kayyem, an assistant secretary of homeland security in the Obama administration. “Once the military is seen as a solution to a public health problem, it’s hard to get the military out of the way.”

The United States, where troops have been limited to missions such as disinfecting public spaces, is increasingly an exception in its refusal to use them to back up new public health restrictions.

“No prime minister wants to enact measures like this,” said Britain’s Boris Johnson. He said Monday that people who violated a nationwide lockdown would be fined.

“We are at war,” said France’s Emmanuel Macron, who deployed 100,000 police officers.

Senegalese President Macky Sall ordered “the defense and security forces to be ready for the immediate and strict execution of the measures decreed throughout the national territory.”

 Those leaders were tapping into a complicated history of security forces responding to pandemics. As 17th-century Britain struggled against the bubonic plague, it imposed selective quarantines on some of its most vulnerable people, perpetuating deep class divisions.

The 1918 influenza pandemic began largely in U.S. Army camps. Instead of containing the virus, deployed troops helped spread it. That was the last time the federal government imposed a large-scale quarantine.

During the 2014 Ebola outbreak, the Liberian military set up a cordon around Monrovia’s West Point slum, considered to be the epicenter of the outbreak. Several residents were shot in clashes with soldiers. Many others slipped through checkpoints undetected. The strategy was eventually abandoned.

Now, as some countries threaten detention and jail time for those who violate lockdowns, public health experts have raised concern about the inherent risk in forcing yet more people into enclosed spaces — an ironic and potentially deadly punishment. In El Salvador and Guatemala this week, photos circulated of police loading people accused of breaking the rules into pickup trucks. The officers and detainees were clustered together with almost zero social distance.

In Jordan, where people are no longer permitted to step outside their front doors, the government has promised its own set of harsh punishments. “We won’t be lenient with anyone who violates the law,” Interior Minister Salameh Hammad told a local news channel.

Public health experts are advising reducing prison populations during the pandemic, not increasing them.

“In cases where people weren’t taking the public health guidance seriously, the military adds this level of gravity,” said Sarah Parkinson, an assistant professor of international relations and political science at Johns Hopkins University. “But if you’re going to arrest hundreds of people and put them in prison, there’s a huge public health risk to that, too.”

In some communities, in the midst of war, the idea of soldiers becoming involved in yet another aspect of their daily lives is haunting.

“We may end up having more deaths and injuries from military brutality than the feared coronavirus,” said Ibrahim Sadiq, a 33-year-old manager at a flour supplier in the Nigerian city of Maiduguri. The city has been targeted by the militant Islamist group Boko Haram for more than a decade, and residents have suffered well-documented human rights abuses at the hands of the army. But if the virus spreads in Nigeria, officials have said, the use of the military is “on the table.”

In Rwanda this week, police shot and killed two young men found violating lockdown orders, authorities said.

As quarantines stretch into weeks or months, it’s unclear the role security forces will play. Will soldiers continue to enforce rules articulated by civilian leadership? Or will their charge evolve?

Already in some parts of the world, military officials have begun not just implementing public health directives but creating them. In Ecuador, which has the highest per capita incidence of covid-19 in Latin America, the hard-hit province of Guayas has been declared a “zone of national security.”

“Operational planning is in the hands of the Armed Forces,” Interior Minister María Paula Romo told La Hora newspaper this week.

Such moves are not uncommon, said Adam Isacson, the director of defense oversight at the Washington Office on Latin America.

“It happens frequently during these crises that civilian capacity is overwhelmed,” Isacson said. “In the Latin American context, the concern is that this could become a more permanent role for the military because of where they are put in the chain of command, and who gets to use resources without consulting anyone. In some places, it can end up supplanting the health ministry.”

Elsewhere, the threat of armed force during the pandemic was more oblique — and not specifically licensed by the state. Grand Ayatollah Ali Sistani, the top Shiite Muslim cleric in Iraq, decreed that those who infected others with the virus could be made to pay “blood money.”

Hezbollah’s leader, Hassan Nasrallah, said, “The virus can be defeated if everyone takes responsibility and plays their part.”

For those who study the role of the state in modern life, and consider what a legitimate use of force is meant to look like in the 21st century, the pandemic poses a massive, unforeseen test.

“There’s a lot of talk about the emergence of a progressive globe after this virus ends, where we care about health care and shift our priorities,” said Kayyem, who now lectures at Harvard. “But it’s just as likely that the new world is one in which more centralized authority is viewed as the norm.” 

Sieff reported from Mexico City. Max Bearak in Nairobi, Danielle Paquette in Washington, James McAuley in Paris, Sarah Dadouch in Beirut, Borso Tall in Dakar and Ismail Alfa in Maiduguri contributed to this report.