Josh Groban can breathe a sigh of relief for the next 5 years ... 'cause that's how long his restraining order against an obsessed fan will last.
The actor/singer had previously gotten a temporary restraining order, but according to new legal docs, obtained by TMZ, a judge has now granted him a permanent order against an obsessive female fan named Shawna Marie Laing. The restraining order will last until August 27, 2025.
TMZ broke the story ... Groban beelined it to court back in June to get a restraining order against Laing, who had allegedly been sexually harassing and threatening the singer since he canceled a date with her nearly a decade ago.
As we reported ... Laing was allegedly drowning him with texts, emails and direct messages since 2011. He also claimed she contacted his family members and his current girlfriend in recent years.
Groban says some of the messages -- as recent as May -- were very sexual and graphic in nature, including one that read ... "I came at approximately 7:09 PM this evening with the thought of your d*** between my t*** and your warmness against my ribcage." That was just the tip of the iceberg.
And now, she's gotta stay the hell away for quite a while.