Newly freed Taliban detainees are processed out of Bagram prison, north of Kabul. (National Security Council of Afghanistan/Reuters)

In Afghanistan, the Taliban has dispatched health teams to far-flung provinces to confront the coronavirus. In Mexico, drug cartels are offering aid packages to those feeling its economic impact. In Brazil and El Salvador, gangs enforce curfews to prevent its spread.

As governments around the world have responded to the coronavirus, so too have armed insurgents and terrorist groups and drug cartels and gangs, a parallel underworld of public health policy and strategic messaging.

It is hardly the first time such groups have attempted to fill the role of government. But few crises in modern times have tested the limits of the world’s nation-states as the coronavirus has, providing an opening for armed groups to step in where presidents, police forces and parliaments have failed.

Public health experts: Coronavirus could overwhelm the developing world

Some groups have attempted to weave governments’ failures to control the virus into their own propaganda narratives. In Somalia, al-Qaeda-linked al-Shabab fighters say the pandemic was spread “by the crusader forces who have invaded the country.” The Islamic State has told followers to prepare to exploit their enemies while they are overwhelmed by outbreaks. In Yemen, Houthi rebels have accused Saudi Arabia of airdropping masks infected with covid-19.

In eastern Afghanistan, where the Afghan government and the Taliban have clashed for nearly two decades, the rivalry over which group has a more effective health policy is now on full display.

Esmatullah Asim, a provincial council member from Wardak province, watched the arrival of Taliban forces in medical gear this month and was impressed. Asim said the government quarantines only those who show symptoms at the border, but the Taliban quarantines every person who has returned recently from Iran.

As coronavirus fears grow, doctors and nurses face abuse, attacks

“The Taliban quarantine is much better than the government,” he said. The group also raises awareness about the virus in the territory it controls, he said. “They stop the vehicles, telling the passengers how to prevent the spread of the virus.”

Even the U.S. State Department conveyed kudos.

“We join the Afghan Ministry of Public Health in welcoming the Taliban’s efforts to raise awareness against #COVID19 and their offer of safe passage to health workers & international organizations working to prevent the spread of the virus,” the department wrote in a tweet.

Analysts who study the organizational structure of armed groups are now cataloguing dozens of instances of rebels and bandits making forays into public health policy.

“In some cases, the government just isn’t coming to help, so this is a chance for nonstate armed groups to appear to be the responsible, accountable actor,” said Sarah Parkinson, an assistant professor of political science and international studies at Johns Hopkins University. “In other cases, it’s concern for their own members. And in others, it’s an attempt to use a piece of evidence in their own propaganda war.”

U.S. allies, encouraged by Washington, said goodbye to their Cuban doctors. As coronavirus surges, some are arguing for their return.

Some governments have acknowledged that armed groups could exploit their weaknesses after the virus fades, seizing on the aftermath of economic dislocation.

The mayor of the Italian city of Palermo, Leoluca Orlando, warned this month that “a den of Mafia jackals” is poised “to exploit the desperation of the new poor from coronavirus.” Other Italian officials have suggested that the mafia could provide its own loans or cash handouts to undermine the government.

In Mexico, at least two drug cartels have begun providing aid packages to residents in places partially controlled by armed groups. In Michoacán, a video emerged last week of the Los Viagras cartel handing out plastic bags of food to hundreds of people. In Tamaulipas, a Mexican state that borders South Texas, photos circulated of boxes full of sugar, oil and other staples distributed in large piles. On the top of each box was plastered the name of the donor: “Gulf Cartel,” they said, “in support of Ciudad Victoria,” the state capital.

As leaders seize powers to fight coronavirus, fear grows for democracy

Falko Ernst, an analyst with the International Crisis Group in Mexico, said there was an “obvious tension” in the effort.

“These groups are trying to be seen as catering materially and providing a notion of security in places where they are also directly preying on the population through extortion and kidnapping and violence,” he said. “But in a lot of places, these groups are the least bad solution for populations that don’t have anywhere else to turn.”

In Brazil’s favelas, the messages come through WhatsApp.

“Whoever is caught on the street will learn how to respect the measure,” one gang warned a Rio de Janeiro slum. “We want the best for the population. If the government is unable to manage, organized crime resolves.”

Last month, as the Salvadoran government was enforcing one of Latin America’s earliest and most stringent lockdowns, leaders of MS-13 decided that they would institute their own curfew. It was a rare overlap of policy between the gang and the government, which have fought each other for years.

Venezuela’s broken health system is uniquely vulnerable to coronavirus. Neighbors are afraid the country will hemorrhage infected migrants.

But it also reflected a reality in much of El Salvador: The police have limited access in neighborhoods under criminal control, and in those places, only a gang-enforced curfew would be observed. MS-13 explained its reasoning to the San Salvador newspaper El Faro: The policy was about protecting its own members, who probably wouldn’t have access to medical treatment if they were infected.

“If there are no respirators left and one of us is gravely ill, all tattooed, and an old woman appears who is in serious condition, they are going to disconnect the gang member and they are going to let him die,” one member said.

A similar overlap in policy has occurred in Afghanistan, where the Taliban has dispatched teams that distribute gloves, soap and masks in areas under its control.

But while the insurgents and the government agree on the need to combat the virus, they continue to fight each other.

“We can’t completely stop our attacks,” Taliban spokesman Zabiullah Mujahid said. He blamed the government for “compelling” them.

Advocacy groups have encouraged more coordination between the Taliban and the Afghan government to tackle the coronavirus. Human Rights Watch proposed videoconferences with “representatives from the Public Health Ministry, the Taliban’s health commission, the U.N. Assistance Mission in Afghanistan and key international humanitarian agencies.”

Brazil’s densely packed favelas brace for coronavirus: ‘It will kill a lot of people’

In many countries, police have been redeployed from rural to urban areas, giving criminal groups more room to operate with impunity — and to enforce their own health policy as the pandemic spreads.

In some cases, “criminal groups will play the role of enforcer with full agreement and even at the request of the state,” wrote Vanda Felbab-Brown of the Brookings Institution. “Such deals in which governments outsource the rule of urban and rural peripheries to criminal groups long preceded covid-19.”

The Washington Post spoke with Syrians in the rebel-held Idlib province, where one million residents have been displaced since late 2019 by fighting. (Video: The Washington Post)

Hayat Tahrir al-Sham, the militant group that dominates Syria’s northern Idlib province, has used the virus to burnish its credentials as a legitimate governing body, issuing orders restricting gatherings and distributing health information to the public.

No cases have been reported in the province. Public health officials and aid workers say the spread of the virus in the crowded refugee camps of Idlib, among a population with little access to health care, would be calamitous.

“The large number of our people gathered in a small geographic space, and the monumental population density in the camps, forecasts disastrous results if the epidemic spreads,” said Ayman Jibis, the health minister for the Hayat Tahrir al-Sham-created Salvation Government.

Sieff reported from Mexico City. George reported from London. Fahim reported from Istanbul. Sharif Hassan in Kabul; Haq Nawaz Khan in Peshawar, Pakistan; and Sarah Dadouch in Beirut contributed to this report.

Mexican factories boost production of medical supplies for U.S. hospitals while country struggles with its own coronavirus outbreak

Coronavirus on the border: Why Mexico has so few cases compared with the U.S.

Soldiers around the world get a new mission: Enforcing coronavirus lockdowns

Today’s coverage from Post correspondents around the world

Like Washington Post World on Facebook and stay updated on foreign news

Coronavirus: What you need to know

Covid isolation guidelines: Americans who test positive for the coronavirus no longer need to routinely stay home from work and school for five days under new guidance planned by the Centers for Disease Control and Prevention. The change has raised concerns among medically vulnerable people.

New coronavirus variant: The United States is in the throes of another covid-19 uptick and coronavirus samples detected in wastewater suggests infections could be as rampant as they were last winter. JN.1, the new dominant variant, appears to be especially adept at infecting those who have been vaccinated or previously infected. Here’s how this covid surge compares with earlier spikes.

Latest coronavirus booster: The CDC recommends that anyone 6 months or older gets an updated coronavirus shot, but the vaccine rollout has seen some hiccups, especially for children. Here’s what you need to know about the latest coronavirus vaccines, including when you should get it.