EXCLUSIVE

New disturbing details in the Jonathan Martin case ... we've learned he was arrested with a cache of weapons including a loaded shotgun, knife and an ax -- and had been threatening classmates for years.

TMZ Sports has obtained court documents filed after Martin was taken into custody on Feb. 23 after posting a cryptic photo on Instagram threatening old high school classmates and former NFL teammates.

Officials say they found Martin after getting a call about a "suicidal male with a gun" at a hospital in Glendale, CA.

He was placed on a 72-hour psychiatric hold because officials believed he was a possible danger to himself and others.

They searched his car and found a loaded 12-gauge shotgun, a large knife, an ax and a cell phone. A second shotgun was found at his parents' home.

Officials spoke with Martin's girlfriend who said he'd been angry and depressed since she met him, but over the past month started making suicidal statements.

The GF says Martin had also been "writing on the walls" of his home.

Investigators spoke with the two former high school classmates Martin tagged in his cryptic IG post who said Martin had been sending them disturbing Facebook messages starting in 2016.

One message said, "Thank you for being such an asshole to me when I was a kid and didn't fit in ... being dicks to me when I was a kid has made me, quite literally, insane."

"And I blame you above all. You'll get yours, eventually -- I have already paid my price for being a bad person. I wish you nothing but the worst. Best, Jonathan Martin."

He sent a second message to the same classmate that said, "You're a bad person. You irreparably damaged people's lives. And you will be exposed publicly. If there is anything else I accomplish in life, it will be making sure you are outed and shamed for who you are."

Martin followed up with a 3rd message that had similar language.

The classmate says Martin apologized in August 2016 and it sounded like everything was cool. Clearly, it was not.