In recent years, Mr. Marten often played chess in the southwest corner of Union Square. At trial, witnesses said he had just finished playing a match when he walked over to a nearby subway entrance, declared he was angry at white commuters and vowed to “knock out” the next one he saw.

Seconds later, he slugged Jeffrey Babbitt, 64, a retired train conductor from Brooklyn who was coming out of the subway on his way to a comic book shop. The punch landed with such force to Mr. Babbitt’s face that he collapsed backward, slamming his head. He died several days later at Bellevue Hospital Center. Mr. Marten also punched two other men who came to Mr. Babbitt’s aid, knocking one out.

“There is no justification for street violence of any kind, but street violence fueled by hatred and prejudice is particularly inexcusable,” the Manhattan district attorney, Cyrus R. Vance Jr., said in a statement. “As the jury concluded, this was not a series of random attacks. Lashawn Marten targeted victims solely on the basis of their skin color.”

The lead prosecutor, Matthew Bogdanos, argued Mr. Marten deserved the maximum sentence allowed — 42 years in prison. He pointed out the defendant had been convicted of three other assaults, including two on police officers in Newburgh, but had never served more than 30 days in jail.

That Mr. Babbitt was chosen at random because of his race made the crime hard to forgive or to understand, Mr. Bogdanos said. “What makes sense about this?” he said. “It defies understanding.”