Her parents, both in their 20s, travelled to Isis territory in Syria in 2015 and lived in the terrorist strongholds of Mosul and Raqqa before appearing at the Turkish border two years later and being detained.

Their daughter was born in Syria in late 2016 and was left with her mother after her husband was detained by Turkish authorities.

British government officials demanded a DNA test to prove the child’s parentage before they were both deported to the UK.

The mother was arrested and questioned but not prosecuted, and her daughter was placed with her grandmother after Judge Gwynneth Knowles found she had lied about her intentions in travelling to Syria.

“I found that the mother’s extremist ideology placed J at risk of being radicalised and of developing a similarly extremist ideology,” she ruled.

“J’s young age does not mean that the risks of such harm are mitigated.”