Taylor Swift's latest obsessed fan won't be facing a jury of his peers anytime soon -- the judge says he's mentally unfit to stand trial.

Mohammed Jaffar had a court hearing Monday in New York, where a judge declared he couldn't be tried on the stalking charge against him in his current state, and would remain in custody -- at a mental health facility -- until he is fit for trial.

We broke the story ... Jaffar showed warning signs of his obsession with Taylor as early as 2014 through tweets that became more brazen and troubling over time.

He was busted earlier this year when cops discovered he'd been camping out on the roof of Taylor's building, and buzzed her doorbell for an hour straight.