Katy Perry just got a little peace of mind -- a judge granted a permanent restraining order against the man she claims has been stalking her and directing threats at her family.
According to new legal docs obtained by TMZ ... 38-year-old William Terry must stay 100 yards away from Katy, her fiance Orlando Bloom, their newborn baby girl, and Orlando's son Flynn from his previous marriage to Miranda Kerr for the next 3 years.
Terry's also prohibited from trying to contact Katy, her family or her staff on social media or posting anything about her ... and has to stay away from her concerts or live performances.
We broke the story ... Katy sought protection from Terry after he allegedly jumped the fence at her Beverly Hills property in September and was busted by cops for trespassing.
Katy claimed Terry tried to do this in August as well, after posting alarming messages on social media for months leading up to it. She feared he'd try it again if she did not get court-ordered protection.
Terry's troubling online behavior allegedly included numerous graphic and sexually explicit posts about Katy, comments about killing dogs and cops, threats to "snap Orlando Bloom's neck" and wishing Flynn and Miranda would "catch covid and die."
As you know ... Katy just became a mother for the first time in August, and hopefully, she now has one less thing to worry about while raising her daughter, Daisy Dove Bloom.