Pablo Tarazaga-Orero, 26, left the Brit Award-winner feeling "scared" and "very uncomfortable" after sleeping outside his house and posting notes and money through his letter box.
Spanish-born Tarazaga-Orero denied any wrongdoing, claiming the former One Direction star had propositioned him, but was convicted after trial last week at Hendon Magistrates Court.
Sentencing him at the same court today, District Judge Nigel Dean banned him from going within 250m of Mr Styles, his home or business addresses or attending any concert or event where he is due to appear.
He was also barred from contacting him directly or indirectly, or posting about him on social media.
Tarazaga-Orero was made the subject of a 12-month community order and told to complete a 30-day rehabilitation requirement.
Judge Dean said: "You should be aware that failing to comply with a community order is a criminal offence and carries a maximum five-year prison sentence."
Prosecutor Katy Weiss said: "I spoke to Mr Styles yesterday and he's adamant he wants [the defendant] to get help although he doesn't want to see him again."
At trial, the court heard Mr Styles first came in to contact with Tarazaga-Orero after noticing him sleeping rough close to his north London home, and offered him money to get food or a hotel.
Mr Styles told the court: "I thought it was sad that someone so young was sleeping rough at a bus stop when it was cold."
Tarazaga-Orero asked if he could have some edamame beans because he is vegan, the court heard.
The following day, the singer returned with two sandwiches, two salads and two muffins from a vegan cafe, but decided to stop interacting with the defendant because of his "odd" behaviour.
Styles told the court: "He asked me if I wanted to go to a restaurant to eat.
"I told him I was on my way to work.
"I found it a little odd. His facial expression made me feel a little uneasy. It was like a smirk.
"Until that point, I never felt unsafe or uneasy in my own home."
Despite cutting contact with the man on the advice of his security staff, Mr Styles continued to see Tarazaga-Orero "incredibly often ... almost every day".
In April, Tarazaga-Orero posted change to the value of £49.95 through his letter box.
The star said he was also followed into a local pub a number of times and was stopped on a run on 30 May when Tarazaga-Orero asked for money.
Tarazaga-Orero claimed he chose to sleep in Mr Styles' neighbourhood after he became homeless in February because it felt safer than central London.
He said he could make up to £100 from the public each day, adding: "I was surprised and many people helped me."
When asked whether he had stalked the celebrity, Tarazaga-Orero said: "That was never my intention. In the end I just wanted the money he offered me."
He denied being obsessed or in love with Styles.
The defendant suggested the pop star propositioned him, telling the court he had said "let's come to a hotel, let's have some fun', or something like that".
The court heard Tarazaga-Orero's stalking still has a "significant effect on [Styles'] day to day life".
Mr Styles said: "I never really encountered this kind of behaviour before. I've employed a night guard. I continue to lock my bedroom door at night."
He also said he continues to check for weak spots in his home.
Tarazaga-Orero carried a copy of the Gita - a Hindi holy book adopted by the Hare Krishna movement - and wore a necklace of paper flowers in the dock.