A teenager who tried to abduct a child from a primary school so he could sexually abuse her has been locked up for 18 months.

Bahader Hassankhail, 18, pretended to be the cousin of an 11-year-old he had groomed online in a bid to take her from her school in Croydon on July 21 last year.

Hassankhail, of Wychwood Avenue, Thornton Heath, bombarded the girl with sexually explicit messages in the months before the attempted abduction, which only failed because she refused to leave with him.

Prosecutor Sam Main told Croydon Youth Court on Thursday: "There was conversation about having children - not just about having children but about how they would have sex."

After an abortive attempt to meet the girl at Tesco in Thornton Heath, Hassankhail went to her school and told the receptionist he had been sent to collect her by her mother, who he claimed was his aunt.

Mr Main said: "[The girl] was brought through to the reception area.  Even at some distance it was clear that she was a very young child.

"Even having seen her seen here and being confronted with her age, Bahader continued trying to take her from her from the school."

He added: "It was only [the girl's] refusal that kept her safe and secure in the premises."

School staff reported the attempted abduction to the police, who issued an appeal in a bid to trace Hassankhail. He was arrested after an officer spotted him on a bus on August 14. 

Detectives seized his mobile phone, on which they uncovered chatroom messages to a 14-year-old who he repeatedly called "sexy". 

Mr Main said Hassankhail's web history showed "an inordinate and unusual amount of pornographic material", including searches for girls aged under 18 and videos depicting sex between parents and children.

Hassankhail was found guilty of attempting to take a child from a person having lawful control following a trial at Croydon Youth Court on December 10.

At a sentencing hearing on Thursday, his lawyer Tamsin Ryder, said in mitigation that Hassankhail was "extremely vulnerable" and had suffered "quite horrendous experiences" throughout his life. 

She told the court the Afghan teenager had lost most of his family at a young age, suffered "attempted brainwashing at the hands of the Taliban" and had lived an isolated life without any responsible adults. 

Miss Ryder appealed for Hassankhail to be spared a custodial sentence, which she said would put him at great risk.

But district judge Peter Greenfield said Hassankhail, in denying the charge, had forced the 11-year-old girl to give evidence at his trial and "relive in some respects what you did that day". 

He dismissed the teenager's claims that he thought the girl had been a 16-year-old Croydon College student, pointing out her school was clearly signposted as a primary school and had a children's play area visible from outside. 

He said: "Nevertheless you proceeded to take her away from her lawful custody." 

Judge Greenfield said he was "not quite clear what would have happened to [the girl] that day", but added: "Your attempt at meeting the girl at the school was clearly for some sort of sexual relationship.

"I have come to the clear conclusion that your attempt to abduct her was sexually motivated."

He sentenced Hassankhail to a 18-month detention and training order, of which he will serve half in custody.