A hardware store clerk who killed and dismembered an 8-year-old Brooklyn boy in 2011, stunning both the close-knit Orthodox Jewish community where they lived and the city, was sentenced Wednesday to 40 years to life in prison.

Levi Aron, 37, who kidnapped Leiby Kletzky as he walked home on a summer day in Borough Park before killing him and stuffing some of his remains in a suitcase, barely spoke during the brief proceeding in State Supreme Court in Brooklyn.

When asked by Justice Neil J. Firetog to comment before being sentenced, Mr. Aron, who sat slumped in an orange prison jumpsuit, a skullcap atop his head, whispered a “no” that was barely audible in the courtroom.

Mr. Aron, who has a history of mental illness, had faced the possibility of a life sentence. But under a deal worked out with the district attorney’s office this month, Mr. Aron pleaded guilty to one charge of second-degree murder and one charge of second-degree kidnapping, which carry lighter sentences.