Brooklyn, NY -In the middle of the night, a man with a history of mental illness slipped into the headquarters of a major Jewish organization in Brooklyn and stabbed an Israeli student in the head as he was studying in the library.

Then, as the screaming, bloody victim was taken away, the attacker lunged at police with his knife and was shot and killed, authorities said.

Calvin Peters, 49, could be seen on amateur video waving the knife inside the Chabad-Lubavitch headquarters in Crown Heights around 1:40 a.m. Tuesday after the attack on 22-year-old Levi Rosenblat. Rosenblat, wounded in the side of the head, was listed in stable condition.

Police said the stabbing was not believed to be connected to terrorism. But it shook the Jewish community, still reeling over an attack on a Jerusalem synagogue by two Palestinian cousins last month that left four worshippers and an officer dead.

“The entire Jewish community is impacted by these cruel and senseless attacks,” said New York state Assemblyman Dov Hikind, whose Brooklyn constituents are largely Orthodox Jews. “How can we help but be reminded of the recent, horrible tragedy … which left five innocent people dead?”

At least one witness said he heard Peters repeatedly saying, “Kill the Jews!” according to Rabbi Chaim Landa, a Chabad-Lubavitch spokesman.

Police were still interviewing witnesses but quoted Peters as saying instead, “I’m going to kill all of you.” The case was not immediately classified as a possible bias crime.

Chabad-Lubavitch is a large, worldwide Hasidic movement that runs schools, synagogues and other institutions and reaches out to nonobservant Jews to encourage them to embrace their heritage and religious traditions. It is active on college campuses and in cities around the globe.

Peters had wandered into the building earlier Monday and was ushered out, then returned after midnight and asked: “Do you have any books in English?” before he was escorted out again, police said. The building, which also contains a synagogue, is open 24 hours a day.

Chabad-Lubavitch officials said security at the building was tightened after the stabbing. They would not say what measures were in place at the time of the attack.

Devorah Halberstam, whose son Ari was killed in a 1994 shooting on the Brooklyn Bridge, said there is nothing more sacred in the community than shul, or synagogue.

“This is where we feel the most safe, when our kids leave the house and we know they went to shul either to pray or to learn,” she said. “To know that something like that has happened and infiltrated within our own community is so troubling.”

The jerky clip of the final confrontation posted online showed Peters in a waist-length jacket and hat with a knife in his right hand, surrounded by officers with drawn weapons and Jewish students wearing traditional plain Orthodox clothing.

Some of the students appeared to be trying to defuse the situation, urging Peters to calm down and asking officers not to shoot him.

Peters eventually put the knife down at an officer’s urging and stepped away, but quickly picked it up again as the officer approached him, apparently to arrest him.

Officers yelled at him repeatedly to drop the weapon as Peters moved around, and a single gunshot could be heard. The shooting itself took place outside camera range.

Police said Peters had lunged at the officer with the 4½-inch blade.

Chaim Grossbaum, a 19-year-old who was studying at the center, said Peters had put his knife down, then picked it up again, “and starts walking toward them, and then the cops shoot him.”

Peters had a documented history of mental illness and had been arrested 19 times since 1982, most recently in 2006 for drugs, police said.

Attorney Jeffrey A. St. Clair, appearing at the Peters family’s front door in Valley Stream, on Long Island, described him as bipolar. St. Clair said the family had no warning of an outburst.

“Calvin Peters was a loving and devoted father,” he said. “And the family is quite frankly shocked and disappointed at what happened.”

Next-door neighbor Lorraine McCartney called Peters as “a very nice man” who had attended parties in her backyard. “I would never believe that of him. Never,” she said.

The Crown Heights neighborhood is home to a large ultra-Orthodox Lubavitch community and was the site of racially charged riots between Jews and blacks in 1991 following the fatal stabbing of a rabbinical student.

In 2008, Pakistani gunmen attacked a Chabad center in Mumbai, India, as part of a rampage through the financial capital that left 166 people dead, six of them at the Jewish site.