Miley Cyrus cannot be contacted by an obsessed fan who says he'd rather die than live without her ... a judge just ruled the guy can't come anywhere near her for 3 years.
Lawyers for Miley were in court today getting a permanent restraining order against Devon Meek ... who was arrested May 16 near her home. He told cops if he couldn't meet Miley, they might as well shoot him in the head.
Meek must stay 100 yards away from Miley for three years ... he also can't come near any of the venues where she performs ... according to the court order.
Meek claims he hears screaming voices in his head and thinks Miley is talking to him through the radio.
Law enforcement sources tell us ... he is still being held for psychiatric treatment, and he's vowed to keep pursuing Cyrus even when he's released from the hospital.