A 33-year-old Eritrean immigrant pleaded guilty before State Supreme Court Justice Deborah A. Haendiges on Thursday to a charge of attempted murder for stabbing his estranged wife repeatedly Jan. 14 at the Wegmans Food Market on Amherst Street.

Awet Gebreyesus, of Busti Avenue, was making a custody exchange of their young son at a public place because of threats he had made earlier. He admitted stabbing his wife in the head and upper body repeatedly as the child witnessed the attack. Store patrons went to the aid of the 26-year-old victim, whose name was not made public.

Rachel Newton, chief of the Erie County District attorney’s Domestic Violence Bureau, said the wound to the skull severed an artery, putting the victim in the hospital for several weeks.

Gebreyesus, who was mistakenly released from the Erie County Correctional Facility on March 8 because of a clerical error, was recaptured by Erie County sheriff’s deputies the next day. He faces a prison term of up to 25 years when he is sentenced May 15.

Newton said the suspect pleaded guilty to the highest charge an Erie County grand jury lodged against him and for which he had faced trial. District Attorney Frank A. Sedita III, after the plea proceeding, praised the unidentified shoppers who went to the aid of the stabbing victim. “Because of their bravery, the victim survived the defendant’s vicious attack,” Sedita said.

The prosecutors said Gebreyesus is likely to be deported when he completes his state prison term.