A man who stabbed a 9-year-old boy to death on the Upper West Side punched his defense lawyer in the face on Wednesday afternoon at State Supreme Court just minutes after a jury determined he was not criminally responsible by reason of insanity.

It took more than two dozen court officers to subdue the defendant, Alejandro Morales, 31, as he crashed around the Manhattan courtroom, swinging wildly at the officers, slamming into the prosecutor’s table and ending up sprawled face down in the jury box, witnesses said.

“He’s a very disturbed and volatile man, and we saw stark evidence of that, unfortunately,” said the defense lawyer, Frederick L. Sosinsky, who was not seriously injured. He added that Mr. Morales became violent after being told he would not go home immediately.

Mr. Morales, a felon who has been repeatedly diagnosed with paranoid schizophrenia, confessed to the police he had killed the boy, Anthony Maldonado, at 3:30 a.m. on Jan. 2, 2010, inside the apartment of Mr. Morales’s mother. At the time, Mr. Morales was on parole for an assault conviction and was taking antipsychotic medication.