In the case heard at Hendon Magistrates' Court in London, 35-year-old Myra Carvalho allegedly stalked the singer, sending her more than 8,000 letters in less than a month.
Carvalho was sentenced to 14 weeks in prison after pleading guilty to harassment. Carvalho, who was also ordered not to attend any event where Harry Styles performed, was given a 10-year restraining order.
It was stated that Myra, who was learned to have a wife in Brazil, left home without her family's knowledge and "expressed that she had sexual urges" towards the 30-year-old singer at the hearing.
Her lawyer Clementine Simon told the court that her client's doctor in Brazil believed she was suffering from a "manic episode" and questioned her fitness to mount a defense.
Carvalho was also ordered to pay a "victim surcharge" of £134.