A judge has decided that the man who stalks Harry Styles must from now on stay at least 250 meters away from the singer. He is also no longer allowed to come to the house and workplace of the singer, BBC reports.

The suspect, who has the Spanish nationality, was also sentenced to community service. He must also spend thirty days in a rehabilitation center. He is also not allowed to post anything about the singer on social media. If he breaks these rules, he risks a prison sentence of up to five years.

25-year-old Styles testified against the 26-year-old homeless man who slept near the pop star's house in London. The singer explains that he had offered the man to book a night for him at a hotel and bought food for him. On the advice of his bodyguard, however, he then decided to stop contacting the Spaniard because of his "strange behavior."

The man is said to have harassed Styles several times on the street and tossed notes and money into his letterbox. He told the judge that the former One Direction singer tried to seduce him to go to a hotel room.

Singer hopes never to see stalker again

Styles said in his testimony that he hopes the man will get professional help and that he will never have to see him again. The singer says he has felt unsafe with the homeless man around his home.

Styles made a musical comeback earlier this month with its new single Lights On . It is not yet clear when his second album will be released.