A ban on pregnant girls attending school in Sierra Leone must be scrapped, a regional West African court ruled on Thursday in a case brought by rights groups.

The ECOWAS Court of Justice demanded that “the prohibitive policy be reversed immediately”, calling it “discrimination against pregnant adolescent girls”.

Sierra Leone banned pregnant girls from going to school in 2015 following the 2014 Ebola crisis — during which thousands of girls became pregnant, often because orphans turned to prostitution, or as a result of rape and abuse.

Officials had argued that pregnant girls would be unable to learn and might influence other girls to get pregnant, but rights groups said the move was discriminatory.

Hannah Yambasu of WAVES, one of the groups that brought the case, said the court’s decision was vital for “ensuring girls are protected and ensuring that girls finish their higher education”.

The ruling was a “landmark moment”, according to Amnesty International’s Marta Colomer, but she warned that national governments do not always enforce decisions from ECOWAS, the Economic Community of West African States.

“The problem is in the past, we’ve seen some of Ecowas judgments have faced difficulties to find themselves enforced,” she said.

Justice Dupe Atoki at the ECOWAS court not only called for an end to the prohibition but also criticised efforts by the UN and the British government to provide a limited education for pregnant youngsters.

“That establishment of schools for pregnant adolescent girls where four subjects are taught in three days in a week is discriminatory and a violation of rights to equal education,” she said.

The ECOWAS Court, set up by the fifteen member states, issues decisions that are supposed to be binding, but often are not acted upon.

Women and girls in Sierra Leone face high levels of sexual violence -– a legacy of the use of rape as a weapon during the civil war of 1991-2002.

For a year after the 2014 Ebola Crisis, which killed almost 4,000 people in Sierra Leone and spread across West Africa, schools were closed to help authorities curb the deadly virus.

But after they reopened reports of stigma were rife.

In 2015, a group of 5,000 girls were expelled for getting pregnant during the Ebola crisis, before the decision was reversed by the government.