Singer Harry Styles told a court he locked his bedroom door every night after being stalked by a homeless man he “felt sorry for”.
Mr Styles, 25, offered to buy Pablo Tarazaga-Orero, 26, food after he saw him sleeping rough outside his London home in March.
Speaking at Hendon Magistrates’ Court, Mr Styles said the man’s behaviour was “erratic and frightening”.
Mr Tarazaga-Orero allegedly followed him and posted notes in his letterbox.
The former One Direction singer said he was “sad to see someone so young sleeping rough” when he first saw Mr Tarazaga-Orero.
Mr Styles then bought him vegan sandwiches, salads and muffins, after the rough sleeper asked for edamame beans.
The defendant allegedly asked Mr Styles if he wanted to go to a restaurant, and smirked at him, which made the singer feel “uneasy”.
After trying to cut contact, the pop star saw him nearly every day, and received notes and money in his letterbox, District Judge Nigel Deane heard.
Speaking at court, Mr Styles said he still checked for “weak spots” in his home.
The trial continues.