EXCLUSIVE

The WWE got an emergency restraining order against an obsessed fan who carried out a poop-smearing attack on a WWE training facility ... fearing he would strike again.

TMZ Sports has obtained court docs showing Vince McMahon's company had a very real fear of Armando Alejandro Montalvo -- who's allegedly been harassing the company since 2015.

According to the court docs, Montalvo smeared his own feces all over the walls at the WWE Training Center in Orlando back in July 2015.

He continued his bizarre campaign against the company in the following days ... wearing makeshift wrestling costumes, banging on the doors and threatening staffers.

On at least one occasion, he was subdued by cops at gunpoint.

In March 2018, Montalvo again surfaced at a WWE event venue in Florida and began harassing employees -- screaming, "My new wrestling nickname is Generation Flex because my d*ck and my balls is bigger than Generation Ex."

WWE says they learned Montalvo posted an Instagram message on April 4 cryptically threatening WWE wrestlers and staff -- and rushed to court to get an immediate restraining order against him because they fear he's a serious threat.

WWE says Montalvo has also threatened to use his own semen in a biological attack.

Court records show the restraining order was granted.