A 31-year-old man who stalked singer Lily Allen for years has been sectioned by a judge under the Mental Health Act. Alex Gray, from Perth in Tayside, had been convicted of burglary and harassment in April at Harrow Crown Court and was sentenced today (June 10).

Lily AllenLily Allen’s stalker has been sectioned.

Gray began pursuing Allen in 2008 and the singer was first made aware of him in 2009 when he set up a twitter account with the handle @lilyallenRIP and then claimed he had written her hit 'The Fear'.

More: Lily Allen Faces Backlash Over Her Criticism Of Rita Ora's Prince Tribute

Then in October of last year Grey broke into Allen’s home when she was asleep with her two children. According to Allen he had an object stuffed in his jacket which appeared to be a knife. She said that luckily there was another adult staying in the house at the time which seemed to scare Grey off.

In a victim impact statement read in court Allen said she was "left terrified for my and my children's safety”. During sentencing, Judge Martyn Barklem said: ”This was a terrifying experience for (Lily Allen), and it was extremely fortunate there was an adult male in the property who evicted Mr Gray from it."

Speaking about her ordeal to The Observer in April, Allen said: “It has affected how I live my life. I’m very wary, I have trust issues. It impacts on your relationships, everything. I’m practically a hermit now!”

More: Lily Allen Reveals She Was Stalked For Seven Years

“I’m very aware of trying not to overdramatise what’s happened, I’m aware that some fears are irrational; I know he is in prison. If I hear a bang, every little noise makes me start. I see his face in people in the street. I’ve had to leave the flat I loved, move nearer a main road with lots of CCTV about.”