Open this photo in gallery:

A man reads a newspaper at a newsstand in Abuja, Nigeria on June 5, 2021.AFOLABI SOTUNDE/Reuters

Nigerian politicians and activists, ignoring threats of arrest, are defying an official ban on the use of Twitter as the government faces a growing uproar over its unexpected attempt to shut down the social-media platform.

Human-rights groups and Western governments, including Canada, have sharply criticized the Nigerian government for its announcement on Friday that it was banning Twitter.

The announcement was swiftly followed on Saturday by a block on Twitter access by all of Nigeria’s biggest mobile phone services. The companies said they were obeying the government’s instructions.

Opinion: With Nigeria verging on failed-state status, West Africa arrives at a tipping point

Most kidnapped schoolboys in Nigeria said to be rescued hours after Boko Haram claims responsibility for abduction

Protests in Nigeria: A look at what’s fuelling the unrest and what it could mean

Nigeria’s Attorney-General, Abubakar Malami, threatened to arrest and prosecute anyone who violates the ban. But huge numbers of Nigerians were continuing to tweet on Sunday, evading the restrictions by using a virtual private network, or VPN, to disguise their location.

“I hope we have today made it clear enough to the Nigerian government that We the People extremely oppose the #TwitterBan,” tweeted Oby Ezekwesili, a former Nigerian cabinet minister and an early leader of the #BringBackOurGirls campaign to rescue the kidnapped Chibok schoolgirls in northern Nigeria.

Nigerians have a “moral responsibility” to disobey any unjust rules, she said. In the Chibok campaign and other social movements, Twitter has “enormously helped the emergence of engaged citizens,” she said.

Nigerian political scientist and activist Jibrin Ibrahim said the Twitter ban has turned the government into an “object of ridicule” around the world. In tweets on the weekend, Mr. Ibrahim said it was “madness” that the government was focused on a Twitter ban at a time when it faced a wave of kidnappings and massacres by insurgents and criminals in northern Nigeria.

Twitter has become a key political tool in Nigeria in recent years – not only on the Chibok issue but in many other campaigns. Twitter was crucial in mobilizing thousands of young Nigerians in mass protests against police brutality last year, culminating in the disbanding of a notorious police unit, the Special Anti-Robbery Squad, or SARS. More than 28 million tweets used the #EndSars hashtag in the campaign to disband the unit.

After the anti-police protests, the Nigerian government threatened to introduce new laws to regulate the use of social media.

Polls by the Afrobarometer survey organization have found that Nigerians are among the strongest supporters of social-media access in Africa. A poll last year found that 61 per cent of Nigerians supported unrestricted access to the internet and social media – one of the highest levels of support among the 18 African countries surveyed – and only 23 per cent wanted the government to regulate access.

While the government of President Muhammadu Buhari has been feeling pressure from protests organized on Twitter, it also has more recent reasons to be angry at the U.S.-based social-media company. It was embarrassed in April when Twitter chose Ghana as its regional headquarters in Africa, even though Nigeria is the most populous country on the continent. And last week it was furious when Twitter deleted a tweet by Mr. Buhari, apparently for inciting violence.

In the deleted tweet, Mr. Buhari had referred to Nigeria’s civil war of the 1960s and issued a threat to treat “those misbehaving today” in “the language they will understand.”

Two days after Twitter deleted this tweet, the government announced the ban on Twitter.

Information Minister Lai Mohammed said the ban was imposed because of “the persistent use of the platform for activities that are capable of undermining Nigeria’s corporate existence.”

He did not explain what this meant. But earlier, he accused Twitter of “double standards” by deleting Mr. Buhari’s tweet while allowing anti-government protesters to foment unrest. “Twitter’s mission in Nigeria is very suspect,” he said.

Only a handful of other governments in the world – including China, North Korea and Iran – have blocked Twitter indefinitely.

Temporary bans on social media, however, have increasingly been imposed by authoritarian governments across Africa as a weapon for suppressing protests during times of unrest.

More recently, the Indian government has been feuding with Twitter and imposing new regulations on it. Last month, Indian police visited two offices of Twitter to demand an explanation for its decision to label several tweets by ruling-party politicians as “manipulated media.”

In Nigeria, the official ban has sparked outrage across the country. Groups such as the Nigerian Bar Association have threatened to take legal action against the ban. Amnesty International and Human Rights Watch have opposed the ban, and diplomats have joined the chorus of criticism.

“Banning systems of expression is not the answer,” said a joint statement by the diplomatic missions of Canada, Britain, the United States, the European Union, Ireland and Norway.

In a statement on the weekend, Twitter said it was “deeply concerned” by the blocking of its platform in Nigeria.

“Access to the free and open internet is an essential human right in modern society,” the company said.

Our Morning Update and Evening Update newsletters are written by Globe editors, giving you a concise summary of the day’s most important headlines. Sign up today.

Follow related authors and topics

Authors and topics you follow will be added to your personal news feed in Following.

Interact with The Globe