A seven-month ban on Twitter use in Nigeria was unlawful, according to a court ruling by West Africa's regional bloc ECOWAS seen by AFP on Thursday.

The Abuja government suspended Twitter in June last year after the social media giant deleted a tweet by President Muhammadu Buhari. It lifted the ban in January.

The Economic Community of West African States (ECOWAS) court issued its ruling following a suit brought by a Nigerian NGO called the Socio-Economic Rights and Accountability Project (SERAP) and rights campaigners.

In a summing-up statement sent to AFP the court said the ban, which drew international approbrium, was unlawful, infringed freedom of expression and access to media, and ran counter to provisions both of the African Charter and the International Covenant on Civil and Political Rights.

In declaring the ban unlawful the court also ordered the Nigerian authorities never to repeat it.

Abuja lifted the suspension after talks with Twitter representatives but laid down conditions, including Twitter registering its operations in Nigeria, Africa's largest economy.

Twitter is widely used by Nigeria's tech-savvy young
Twitter is widely used by Nigeria's tech-savvy young AFP / Olivier DOULIERY

With three-quarters of Nigeria's population of 200 million aged under 24 the country is hyper-connected to social media.

The ban shocked many in Nigeria, given Twitter's major role in political discourse, as evidenced by the #BringBackOurGirls hashtag deployed after Boko Haram extremists kidnapped nearly 300 schoolgirls in 2014.

Young activists also turned to Twitter to organise the #EndSARS protests against police brutality that eventually grew into the largest demonstrations in Nigeria's modern history before they were repressed.

Around 40 million Nigerians, or around 20 percent of the population, have a Twitter account.

Abuja initially announced an unlimited ban, accusing the platform of allowing activities it said threatened the country's existence citing posts by separatist agitators from the country's southeast, where a civil war five decades ago killed one million people.

Nigeria's National Information Technology Development Agency (NITDA) director general Kashifu Inuwa Abdullahi at the time said there were "unscrupulous elements" using Twitter "for subversive purposes and criminal activities, propagating fake news, and polarising Nigerians."

The ban came two days after Twitter took down a tweet from President Buhari warning he would take action and treat those users "in the language they understand."