One day last month, scientists at Moscow’s leading cancer research center realized they had lost access to several online databases crucial to their work. And that wasn’t their only problem.

Most Google services were down too, for all Russian internet users. That mean not only search, Gmail and YouTube, but less high-profile but nonetheless critical services such as CAPTCHA — the widely-used system for verifying that a log-on comes from a real human rather than a bot. With this out of action, many websites were effectively locked shut.

Services provided by other foreign online giants such as Amazon were offline too. The list went on and on. Car dealerships couldn’t process insurance payments. Passengers had trouble checking in for flights. Video-gamers were locked out of their favorite daily addiction.

In the process, Russians were also getting an insight into some of the internet’s more obscure inner workings — and how dependent they were on services outside their borders. The editor of the country’s most popular sports news site announced that they had lost all their type fonts, because the are provided and hosted externally by Google. The internet was literally disappearing in front of the eyes of Russian users.

In all, an estimated 20 million different links, websites and online services had become unavailable within Russia. Codaru.com, Coda Story’s sister website, was among them, because its hosting service was one of the sites affected.

But it wasn’t a technical failure that had caused all this online chaos. It was the Russian government — specifically its media watchdog agency, Roskomnadzor. And all because it wanted to ban a single messaging app, Telegram.

It was the culmination of a battle going back several years. The FSB, Russia’s main domestic intelligence service, has been leading the charge, accusing Telegram of giving the Islamic State and other extremists free reign to use its channels to communicate and inspire attacks.

What has really sparked the FSB’s ire, though, is the refusal of Telegram bosses to grant access to users’ communications. And when it refused to comply with a court ruling earlier this year, demanding that it hand over the necessary encryption keys, the government began its cyber-offensive to try to close the app down.

But while the Russian government is accused of all kinds of high-tech cleverness in interfering in elections and information warfare abroad, it hasn’t lived up to that image on the home front. In fact, its battle with Telegram has turned into a humiliating own-goal, making it look incompetent while also inflicting billions of rubles of losses on Russian business.

Blatant hypocrisy

Faced with a barrage of criticism and outright scorn, Roskomnadzor threw in the towel in early May and started unblocking large groups of IP (internet protocol) addresses. And after all this, Telegram itself is still available, albeit with a sometimes spotty connection.

Along the way, it has exposed the weaknesses of the Russian censorship machine, as well as the government’s blatant hypocrisy. Russian Telegram users barely make up 10 percent of its global base, but it is used by everyone of any importance in the country.

Even after the ban came into effect senior officials admitted that they were still using Telegram — including Vladimir Putin’s spokesman, Dmitry Peskov. He said he saw “nothing wrong” in doing so.

When a Russian parliamentarian asked her Facebook followers not to contact her on Telegram — because the messages weren’t getting through — the spokeswoman for the Russian prime minister, Natalya Timakova, responded with a note saying they could install a VPN (a virtual private network service) to circumvent the ban, because “it’s just so easy.” She later claimed she had meant this as a joke.

Opposition channel

The story of Telegram has been one of relentless friction with the Russian government, since the app was first launched by its founder Pavel Durov. Russian lawmakers first floated the idea of banning it in 2015, on the grounds its channels were being used by the self-styled Islamic State. Durov famously retorted: “I suggest banning words. Reportedly, they are used by terrorists to communicate.”

Telegram does indeed have a history of being used by IS to recruit and train, and in at least one confirmed instance, to coordinate attacks. The FSB goes further, saying that the app has been used in almost every recent terror incident on Russian soil.

But Telegram is also the communication channel of choice for many Russian opposition groups, something that also irks the Kremlin’s intelligence agencies.

Two years ago, the government started turning up the heat. It introduced an amendment to Russia’s anti-terrorism legislation requiring any service involved in the “dissemination of information” to decrypt customer messages at the request of the FSB.

Durov refused, telling the Russian authorities that he would wipe out the extremists’ channels himself, without compromising Telegram users’ privacy.

But that did not sit well with the FSB, and the case went all the way to Russia’s Supreme Court. And in March, it ruled in the government’s favor. Durov again refused to hand over his encryption keys, and so in April Roskomnadzor began trying to block Telegram in Russia

It wasn’t so straightforward. For one thing, Russia’s online watchdog is not as powerful as you might think. It can’t block websites on its own. Instead, it is more like a go-between, following the orders of law enforcement agencies and then passing them on to internet service providers (ISPs), telling them to bar certain IP addresses.

The larger, federally-owned providers usually act on these orders immediately. Smaller, regional providers take longer though, and sometimes ignore the orders completely, which is why supposedly banned websites can remain online for hours and even days.

But Roskomnadzor compounded its own weaknesses by showing an amateurish level of understanding of how Telegram works. It is an app, not a website, which means that it is not bound to a single IP address.

Yet the online censor initially targeted it by ordering ISPs to block addresses directly associated with Telegram, including its home page and the web version of its chat service. But that did little to hamper the messenger service’s functionality. Even after the ban came into effect senior officials admitted that they were still using Telegram — including Vladimir Putin’s spokesman, Dmitry Peskov. He said he saw “nothing wrong” in doing so.

For its part, Telegram immediately launched a deft campaign of counter measures — embarrassing the government still further. It sent new settings to users, allowing them to circumvent the ban, and started using a technique called “domain fronting,” which made it appear as though users were accessing entirely different services when they were actually on Telegram.

That is when the collateral damage started to spread across the Russian internet.

When Roskomnadzor realized it was being outfoxed, it reacted by ordering the cyber-equivalent of carpet-bombing, ordering ISPs to block entire subnets, or groups of IP addresses, which Telegram was using for domain fronting.

Even Russian IT giants close to the government, such as Yandex and Mail.ru, were hit. Initially reluctant to oppose the campaign against Telegram publicly, they lost patience when Roskomnadzor briefly added them to its “black list.”

The agency tried to save face by saying that it wasn’t actually attempting to ban the app, but only to “degrade” it. In fact, Telegram was actually growing, gaining thousands of new Russian users as a result of the government’s very public effort to squash it.

One of Telegram’s defining features is its “channels.” In essence, it is a simple blogging platform that allows anyone to broadcast their views and messages to an audience of their choosing. There are channels specializing in feminist writing, history and cooking, and more general political commentary groups with hundreds of thousands of subscribers.

There are also numerous pro-Kremlin channels, both promoting government policy and attacking the opposition. Pro-Kremlin figures also run their own Telegram channels. The editor-in-chief of the government-owned RT network, Margarita Simonyan, has 13,000 subscribers, while RT Russian has almost 50,000 — and both channels have remained active even after the ban.

Telegram has also become an important advertising platform for Russian businesses, with many using popular channels to promote their products and services. So the attempt to ban the service has hit hard, causing losses estimated as high as $2 billion dollars.

The debacle has also been a blow to the government’s long-held hopes of exerting greater control over the internet. The Russian authorities have long toyed with the idea of copying the Chinese model and establishing “online sovereignty” — that is, cutting Russia off almost entirely from the global internet.

But the Kremlin was always going to struggle to achieve this, according to Andrei Soldatov, an expert on the Russian security services and author of “The Red Web,” a book on the country’s digital battles.

China built up its internet infrastructure “with total state control in mind,” he said in an interview, “while Russia only introduced content filtration in 2012.” What is more, Soldatov added, “a whole segment of China’s tech industry is aimed at controlling the online behaviour of individual users.” And all Chinese have to have a surveillance app on their phones. “I wouldn’t credit the civil society with this victory and wouldn’t even call it a victory.” — Sergey Smirnov

Russia, by contrast, is using “the same age-old methods” to try to exert control on the internet, argues Soldatov. And it does not have the equivalent of China’s “Great Firewall,” with the capacity to isolate itself from the rest of the world.

Another crucial difference is that China’s domestic online market is big enough (the biggest in the world, in fact) to be almost entirely self-sufficient. While Russia has homegrown online giants such as Yandex or Vkontakte, it is still deeply dependent on outside services.

So what happens next? Anton Merkurov, an internet expert, says this is a strategic defeat for the Russian government. “The Digital Resistance [a phrase coined by Pavel Durov] did really shine while the state’s impotence couldn’t be more obvious.” As much as the government wants to censor more, Merkurov adds, they’re simply not technically competent enough to do so.

Merkurov predicts a increasing conflict between the state and what he believes is a growing community of tech-savvy individuals who reject censorship, and he says the state will lose.

But not everyone is so optimistic. Sergey Smirnov, the editor in chief of Mediazona, a crowdfunded website that covers political trials and the prison system, is wary. “I wouldn’t credit the civil society with this victory and wouldn’t even call it a victory. This time they weren’t prepared from a technical standpoint, but they’ll draw conclusions for the next time.”