Police say a knife-wielding man stabbed a rabbinical student in the head inside a Brooklyn synagogue Tuesday morning before being fatally shot by police after he refused to drop the knife.

Police say the confrontation happened at 1:40 a.m. at the Chabad-Lubavitch Hasidic headquarters in Crown Heights.

"He was just going crazy," Israel Gottdenger, 26, told The New York Post. Gottdenger told the paper that the man entered the building with him and recalled the man saying, "I want to sit down; I want to get a Bible; who wants to die tonight?"

"He was either really high on drugs or an (emotionally disturbed person)," he said.

A witness flagged down a police officer, who confronted the 49-year-old man and told him to put the knife down. He initially put it down but then picked it up again. More officers responded and ordered the man to drop the knife.

Police say he refused and charged at one of the officers, who fired once, striking the man in the torso.

The dramatic encounter was captured on video. Peters is heard shouting, "You gonna shoot me?" One of the officers, who had his gun drawn, responded, "If you don't drop the knife I will."

The Chabad-Lubavitch Hasidic headquarters keeps its doors open to homeless, so that could be how the man gained access to the building, The New York Times reported.

William Bratton, the police commissioner, said, "It is not a terrorism incident."

The suspected, identified in The Post as 50-year-old Calvin Peters, was taken to a hospital where he was pronounced dead.

Authorities say the 22-year-old stabbing victim was in stable condition.