On his first visit, in October 2004, he found a police officer arresting a student and calling for backup to handle the swelling crowd. Students roamed the hallways with abandon; in one class of 30, only 5 students had bothered to show up. “It was chaos,” Mr. Waronker recalled. “I was like, this can’t be real.”

Teachers, parents and students at the school, which is mostly Hispanic and black, were equally taken aback by the sight of their new leader: A member of the Chabad-Lubavitch sect of Hasidic Judaism with a beard, a black hat and a velvet yarmulke.

“The talk was, ‘You’re not going to believe who’s running the show,’ ” said Lisa DeBonis, now an assistant principal.

At a time when the Bloomberg administration has put principals at the center of its efforts to overhaul schools, making the search for great school leaders more pressing than ever, the tale of Mr. Waronker shows that sometimes, the most unlikely of candidates can produce surprising results.

Despite warnings from some in the school system that Mr. Waronker was a cultural mismatch for a predominantly minority school, he has outlasted his predecessors, and test scores have risen enough to earn J.H.S. 22 an A on its new school report card. The school, once on the city’s list of the 12 most dangerous, has since been removed.

Attendance among the 670 students is above 93 percent, and some of the offerings seem positively elite, like a new French dual-language program, one of only three in the city.

“It’s an entirely different place,” Schools Chancellor Joel I. Klein said in a recent interview. “If I could clone Shimon Waronker, I would do that immediately.”

Not everyone would.

Mr. Waronker has replaced half the school’s teachers, and some of his fiercest critics are teachers who say he interprets healthy dissent as disloyalty and is more concerned with creating flashy new programs than with ensuring they survive. Critics note that the school is far from perfect; it is one of 32 in the city that the state lists as failing and at risk of closing. Even his critics, though, acknowledge the scope of his challenge.

“I don’t agree with a lot of what he’s done, but I actually recognize that he has a beast in front of him,” said Lauren Bassi, a teacher who has since left. “I’m not sure there’s enough money in the world you could pay me to tackle this job.”

Mr. Waronker, 39, a former public school teacher, was in the first graduating class of the New York City Leadership Academy, which Mayor Michael R. Bloomberg created in 2003 to groom promising principal candidates. Considered one of the stars, he was among the last to get a job, as school officials deemed him “not a fit” in a city where the tensions between blacks and Hasidic Jews that erupted in Crown Heights, Brooklyn, in 1991 are not forgotten.

“They just said he may be terrific, but not the right person for that school,” Chancellor Klein said.

Some parents at J.H.S. 22, also called Jordan L. Mott, were suspicious, viewing Mr. Waronker as too much an outsider. In fact, one parent, Angie Vazquez, 37, acknowledged that her upbringing had led her to wonder: “Wow, we’re going to have a Jewish person, what’s going to happen? Are the kids going to have to pay for lunch?”

Ms. Vazquez was won over by Mr. Waronker’s swift response after her daughter was bullied, saying, “I never had no principal tell me, ‘Let’s file a report, let’s call the other student’s parent and have a meeting.’ ”

For many students and parents, the real surprise was that like them, Mr. Waronker speaks Spanish; he grew up in South America, the son of a Chilean mother and an American father, and when he moved to Maryland at age 11, he spoke no English.

“I was like, ‘You speak Spanish?’ ” recalled Nathalie Reyes, 12, dropping her jaw at the memory.

He also has a background in the military. Mr. Waronker joined R.O.T.C. during college and served on active duty for two years, including six months studying tactical intelligence. After becoming an increasingly observant Jew, he began studying at a yeshiva, thinking he was leaving his military training behind.