Kevin McGlynn in September was found unfit to stand trial on stalking charges and committed to a psychiatric hospital in Staten Island. He has filed a petition seeking release.
In a decision released earlier on Friday, Judge Orlando Marrazzo said the order would allow police to arrest McGlynn if he goes near the singer's home, instead of having to wait for him to do something more dangerous. McGlynn is also barred from contacting Rihanna by phone, mail or computer.
Marrazzo said McGlynn, 54, wrote a series of notes to the singer that made references to murder and sexual assault. He also accused Rihanna and other artists of using his material in their songs, the judge said.
In his decision, Marrazzo compared McGlynn to Mark David Chapman, who shot and killed John Lennon.
"He appears to be a ticking time bomb who is wholly fixated on (Rihanna), and poses a direct threat of serious physical harm or death to her and anyone around her," he wrote.