Ivanka Trump’s longtime stalker — a schizophrenic who once blamed his obsession on space aliens — was nabbed less than two blocks from Trump Tower by Secret Service agents, a law-enforcement source has revealed.

Justin Massler, 34, has been in Bellevue Hospital since the Nov. 29 arrest but has not been charged, according to reports.

For years, Massler haunted Ivanka Trump with disturbing e-mails and YouTube videos, including one of him drenched in blood.

He was charged with stalking and harassment in 2010 and pleaded guilty in 2012 to violating an order of protection.

“This man is a total psychopath,” a source said.

Massler lived with his mother in Reno, Nev., according to public records. He disappeared from there on Nov. 23 as he was about to be committed to a mental-health facility, Nevada cops said.

He was at the Salisbury Hotel on West 57th Street when the Secret Service nabbed him, said his brother Jeremy.

“He didn’t choose the hotel,” Massler said. “I never got any indication he wanted to be near members of the Trump family. He came to New York because he has some friends and family here.”

He said it hadn’t occurred to him that the Salisbury was near Trump Tower.