The threats, Mr. Eichenwald wrote, were “sometimes just general invocations that I should die, sometimes more specific threats that I should be shot or ‘lynched,’ as one Trump fan wrote.” He added, “One Trump fan mentioned he knew which schools my children attended, and correctly named them.”

In December 2016, after publication of the Newsweek piece, Mr. Eichenwald told investigators that he had stepped into his home office one evening and clicked on a message from someone identified as @jew_goldstein. It contained a strobe light GIF and a declaration in capital letters: “You deserve a seizure for your posts.”

Looking at the strobe caused an immediate seizure that lasted about eight minutes, court documents showed.

“He slumped over in his chair,” said Steven Lieberman, Mr. Eichenwald’s lawyer. “He was unresponsive and he probably would have died but for the fact that his wife heard a noise — she’s a physician — and she pulled him away from the screen and got him onto the floor.”

Mr. Eichenwald’s wife, Theresa, called 911 and took a picture of the strobing light on his computer with her cellphone. “This is his wife, you caused a seizure,” she replied to the Twitter account. “I have your information and have called the police to report the assault.”

Investigators found several digital clues they said led them to Mr. Rivello, including a message he had sent to other Twitter users that read, “I hope this sends him into a seizure.” They also found a screenshot on Mr. Rivello’s iCloud account showing Mr. Eichenwald’s Wikipedia page with a fake date of death as well as a screenshot of a list of epilepsy seizure triggers that had been copied from an epilepsy information website.

The faked Wikipedia page also included anti-Semitic references, according to court documents, and the Twitter handle @jew_goldstein, with the name Ari Goldstein, was traced to Mr. Rivello.