For a group that espouses ancient moral codes, the Afghan Taliban has used strikingly sophisticated social media tactics to build political momentum and, now that they’re in power, to make a public case that they’re ready to lead a modern nation state after nearly 20 years of war.

In accounts swelling across Facebook, Twitter and Instagram — and in group chats on apps such as WhatsApp and Telegram — the messaging from Taliban supporters typically challenges the West’s dominant image of the group as intolerant, vicious and bent on revenge, while staying within the evolving boundaries of taste and content that tech companies use to police user behavior.

The tactics overall show such a high degree of skill that analysts believe at least one public relations firm is advising the Taliban on how to push key themes, amplify messages across platforms and create potentially viral images and video snippets — much like corporate and political campaigns do across the world.

One image from a video circulated online in Afghanistan shows Taliban fighters dressed in camouflage and brandishing machines guns while posing unmolested in an eastern province, not far from Kabul, under a gorgeous pink and blue sky. The text below, in Pashto and English, reads, “IN AN ATMOSPHERE OF FREEDOM.”

The Taliban was last in power from 1996 to 2001. With the fundamentalist group taking over again, Afghanistan could be a “humanitarian crisis in the making.” (Alexa Juliana Ard, Ishaan Tharoor/The Washington Post)

Wide distribution of such propaganda imagery would have been almost impossible for an insurgent movement there a generation ago, before the arrival of smartphones, Internet connections and free social media services brought unprecedented online reach to Afghanistan. The nation lags the world in Internet connectivity but it has grown sharply over the past decade amid a gush of international investment.

But the audience for much — and perhaps most — of what Taliban supporters push on social media is clearly international. That includes Afghans living in other countries, potential supporters abroad and even the profoundly skeptical Western powers that have poured trillions of dollars into attempting to create a durable, Western-style democracy in Afghanistan since a U.S.-led invasion ousted the Taliban in 2001. The official Afghan Taliban website offers versions in Pashto, Dari, Arabic, Urdu and English. Only the first two are widely spoken in most of Afghanistan.

Recent months have seen an uptick in online messages offering a gentler, more reassuring face of the Taliban, whose brutality during its previous reign over the nation was notorious, featuring mass executions, repressive moral codes and the exclusion of women from schools and workplaces.

“The Islamic Emirate has ordered its Mujahideen and once again instructs them that no one is allowed to enter anyone’s house without permission,” Taliban spokesman Suhail Shaheen tweeted on Sunday. “Life, property and honor of none shall be harmed but must be protected by the Mujahedeen.”

Shaheen has more than 350,000 Twitter followers.

“The Taliban of today is immensely savvy with technology and social media — nothing like the group it was 20 years ago,” said Rita Katz, executive director of SITE Intelligence Group, which monitors online extremism.

Analysts caution that claims of a more evolved and tolerant Taliban should not be taken at face value at a time when a movement that once hosted Osama bin Laden and al-Qaeda reintroduces itself to a skeptical world. The Taliban espouses a profoundly traditional notion of Islam, one that has many Afghans with more modern views fleeing in terror by any means possible.

At the same time, the ability of the Taliban and its supporters to operate substantially within the rules of companies such as Facebook, Twitter and YouTube has left Silicon Valley vulnerable to intensifying political crosscurrents: U.S. conservatives have been demanding to know why former president Donald Trump has been banned from Twitter while various Taliban figures have not.

The answer, analysts said, may simply be that Trump’s posts for years challenged platform rules against hate speech and inciting violence. Today’s Taliban, by and large, does not.

“The Taliban is clearly threading the needle regarding social media content policies and is not yet crossing the very distinct policy-violating lines that Trump crossed,” Katz said.

Katz cautioned, however, that “this doesn’t mean at all that the Taliban shouldn’t be removed from social media, because the waves of propaganda and messaging it is spreading — permissible as it may seem by some content policy standards — is fueling a newly emboldened and extremely dangerous global Islamist militant movement.”

The challenge for American technology companies is complicated by shifting geopolitics as the Taliban takes control, amid divergent designations by even the U.S. government itself. While the State Department has designated the Pakistani Taliban a foreign terrorist organization, it has not applied the same label to the Afghan Taliban. The Afghan Taliban, however, is listed as a sanctioned entity under rulings from the Treasury Department’s Office of Foreign Assets Control (OFAC).

Citing those rulings, Facebook has designated the Taliban a “dangerous organization,” giving it a policy-based lever to pull when it chooses to remove accounts — no matter what the specific posts say. The company even closed down a popular hotline this week that the Taliban had set up on Facebook-owned WhatsApp for people to report incidents of violence, looting and other attacks.

That move has prompted a backlash among those who have worked in the country and have seen the useful role that WhatsApp has played in Taliban operations as it seeks to operate as a government — as opposed to an armed insurgency. WhatsApp, which functions as a primary way Afghans communicate with each other in a country with a rudimentary telecommunications infrastructure, for several years has allowed people in areas where the Taliban had substantial power to register complaints and concerns with the group, including about civilian deaths.

“Now that they’ve taken over the entire country, it becomes very difficult to shut down everything related to them because then, essentially, Afghans suffer,” said former international aid worker Ashley Jackson, author of the newly released “Negotiating Survival — Insurgent Relations in Afghanistan.”

Daniel Knowles, a foreign correspondent for the Economist magazine, noted on Twitter that such WhatsApp setups were common even before the Taliban took power. “I am slightly annoyed I didn’t write about these WhatsApp helplines ages ago,” he said after news of the hotline shutdown was reported. “But when I heard about them, they weren’t ‘helplines’. It was more just, your local Taliban were reachable by WhatsApp, and if you called, they would resolve disputes. It’s just how they govern.”

A person familiar with Facebook’s deliberations, who spoke on the condition of anonymity to talk freely, said Facebook recognizes that U.S. sanctions date to the administration of President George W. Bush and has sought additional guidance from OFAC. In the past, OFAC has created carveouts to the sanction lists for special cases. The Treasury Department, which Houses OFAC, declined to comment.

YouTube also cited compliance with U.S. sanctions in affirming that it will continue to remove accounts “believed to be owned and operated by the Afghan Taliban.”

But Twitter, among some other companies, is allowing the Afghan Taliban more leeway by not removing accounts purporting to speak for it. And U.S. officials in public comments have been careful to note that the administration has made no decision regarding recognizing the Taliban government, or not.

“We are still taking stock of what has transpired over the past 72 hours and the diplomatic and political implications of that,” State Department spokesman Ned Price told reporters Monday.

The Taliban, like other Islamist movements such as the Islamic State and al-Qaeda, long saw opportunity in turning the West’s communication technologies against it — while showing an agility that sometimes frustrated those charged with shutting down or blunting its messages.

Even in the first years after U.S. forces chased the Taliban from Kabul, Afghanistan’s capital, the group delivered propaganda messages through blog posts, said Emerson Brooking, a resident senior fellow for the Digital Forensic Research Lab at the Atlantic Council, a Washington-based think tank.

By 2011, Brooking said, the Taliban was on Twitter, and by 2014 on Telegram. In 2016, the Taliban occupied one key spot in a northern province for only the few minutes it took to shoot a propaganda video that later circulated widely on social media. By 2019, the Taliban had learned to take over hashtags — meaning infuse a popular hashtag with its own messages, a kind of “spammy” behavior that can prompt remedial action by tech companies.

Like other operators of sophisticated social media campaigns, the Taliban and its supporters have large numbers of accounts linked across numerous platforms to keep its messaging machinery from being easily squelched by the actions of one or two tech companies.

“Based on the sheer volume of output, several of the accounts are run by individuals whose primary job may well be social media,” said Darren Linvill, lead researcher for the Clemson University Media Forensics Hub. “These accounts aren’t run by Taliban leaders or fighters, they are run by individuals with uninterrupted Internet access on both a desktop and handheld device, as well as decent English language skills.”

As it became clear in recent months that the Americans were going to finally leave, the Taliban’s tactics grew still more sophisticated, with messages heralding each advance on the battlefield and promising that a better Afghanistan lay ahead.

One message on the Taliban’s English-language website in April attacked feminism as “a colonial tool” and claimed that it “attacks the institution of family in a family-centric Muslim society.” Another the following month espoused the importance of freedom of the press, calling it “essential for every society and country.”

The Taliban’s social media tactics in recent months can be seen as fitting a broader charm offensive — including recent conciliatory public remarks about pardoning those who worked with Americans and urging skilled people not to flee the country. At a news conference Tuesday, spokesman Shaheen made a point of calling on a female journalist and foreign reporters.

But analysts remain wary of the Taliban’s use of social media to repackage itself.

“We should be deeply distrustful of it,” said Brooking. “Recriminations will come later.”

Elizabeth Dwoskin and John Hudson contributed to this report.