A Hasidic man convicted of gang assault in the beating of a black student in Brooklyn was sentenced on Thursday to four years in prison. Within hours, however, the sentence was stayed pending an appeal.

The racially charged beating four years ago in the Williamsburg neighborhood occurred when members of a neighborhood watch group known as the shomrim accosted the victim, Taj Patterson, and accused him of vandalizing cars. Mr. Patterson was chased and beaten, an assault that left him blind in his right eye.

According to the police investigation, there had been no vandalism.

The defendant, Mayer Herskovic, 24, had faced up to 15 years in prison for his role in the attack. But though some of the assailants had clearly meant to cause serious physical injury, there was no proof that Mr. Herskovic had harbored that same intent, a judge in Brooklyn said at his sentencing.

“Among all of the participants who stomped and beat on Mr. Patterson, this defendant was not the most culpable,” said the judge, Danny K. Chun, of State Supreme Court in Brooklyn.

Before he was sentenced, Mr. Herskovic made a brief statement to the court.

“I wish that I could take back what happened to Mr. Patterson,” he said. “I pray that Mr. Patterson finds peace for what he has suffered and endured.”

The beating took place as Mr. Patterson, 26, who was in college studying fashion marketing at the time, was passing through a Hasidic enclave in South Williamsburg on his way home to Fort Greene. Members of the Williamsburg Safety Patrol, who said that they had received complaints about someone damaging cars, chased Mr. Patterson, held him down, then kicked and punched him, breaking his right eye socket.

Up to 20 men took part in the attack, Mr. Patterson testified. The assailants fled when passing motorists intervened. Police officers who responded to the scene spoke with four witnesses and had the license plate number of a car that one attacker used to leave, but closed the case without making any arrests. The police reopened the investigation after Mr. Patterson’s mother spoke about what had happened to her son with the news media.

One compelling bit of evidence against Mr. Herskovic came when prosecutors presented a black Air Jordan sneaker belonging to Mr. Patterson that was hurled onto a roof during the assault. It was recovered by detectives, and prosecutors said that lab tests showed that it bore Mr. Herskovic’s DNA. A witness for the defense said that the testing method used on the sneaker had been imprecise. But a prosecution witness countered that it was reliable.

Mr. Herskovic’s lawyer, Stuart Slotnick, said after the sentencing that he would appeal the conviction, adding, “We think the DNA evidence in this case was completely and utterly flawed.”

About an hour later he said that an appellate division judge had agreed to stay the sentence in anticipation of that appeal and that Mr. Herskovic would be freed that afternoon.

During the sentencing, Mr. Slotnick asked Justice Chun for a sentence of three and a half years, the minimum allowed. He said that Mr. Herskovic, “a hardworking blue collar worker” and father of two, had no previous criminal record and had been active in charities.

A prosecutor, Timothy Gough, said that he had spoken before the sentencing with Mr. Patterson and would convey his thoughts to the judge. At first, he said, Mr. Patterson had wanted to request the maximum sentence but had decided to ask for a sentence of five years, partly out of a desire to “move forward.”

Still, Mr. Gough said, Mr. Patterson, who underwent three rounds of surgery, bore physical and mental scars from the beating. His outgoing nature had been dampened, his belief in a higher power had been shaken and he has often wondered what had caused him to become a target. Mr. Gough appeared to answer that question.

“He was a young black male in a predominantly Orthodox neighborhood,” he said. “This defendant, that group, that community could not see him as an individual.”

A version of this article appears in print on , on Page A25 of the New York edition with the headline: Assailant Gets 4 Years in Racially Charged Beating. Order Reprints | Today’s Paper | Subscribe