The man accused of going on a gruesome machete rampage in December at a Hanukkah celebration in Rockland County that left one man dead is not mentally competent to stand trial for hate crime charges, a judge wrote in a ruling made public on Monday.

White Plains federal judge Cathy Seibel ruled that Grafton Thomas, 37, suffers from a mental illness that renders him. “incompetent to the extent that he is unable to assist properly in his defense.”

The judge based her ruling on a report from a forensic pathologist who conducted a psychological examination on Thomas at Manhattan’s Metropolitan Correctional Center.

Seibel ordered Thomas to be held in a treatment facility for up to four months to determine if there is any chance that he could be fit to stand trial at some point in the future. She also ordered the US Bureau of Prisons to report on Thomas’ mental condition within 30 days.

Thomas is accused of bursting into the Rabbi Chaim Rottenberg’s home in Monsey on Dec. 28 and slashing and stabbing Orthodox Jewish worshipers gathered there for Hanukkah.

“No one is leaving,” Thomas allegedly said before he began his attack, which resulted in five people being hospitalized. Thomas allegedly told a psychiatrist who interviewed him after the rampage that, while he doesn’t clearly remember the details of his frenzy, he did it to “change the complexion of a problematic society.”

Josef Neumann, 72, was critically wounded — the machete cut through his skull and made contact with his brain, his family said in a previous statement.

Neumamn spent months in a coma before succumbing to his injuries in March. Prosecutors have previously said that they would consider pursuing the death penalty for Thomas if any of his alleged victims died.

Seibel’s ruling applies to the federal hate crime charges against Thomas. He is also charged in state Supreme Court with five counts of attempted murder.

As of Monday, Thomas’ charges have not been updated to reflect Neumann’s death.

Michael Sussman, Thomas’ attorney, also has a pending request to dig up Neumann’s body for an autopsy — which is strongly discouraged under Jewish law.