An avowed white supremacist has been sentenced to life in prison without the possibility of parole in the fatal shooting of ten people in an attack at a western New York grocery store last year.

Payton Gendron, 19, had pleaded guilty to a total of 15 state charges including murder and terrorism motivated by hate stemming from the 14 May mass shooting in Buffalo, including murder and domestic terrorism motivated by hate.

Erie County Court Judge Susan Eagan announced the sentence.

The shooting was one of the deadliest in a series of mass shootings in recent years in a country that has grown accustomed to such crimes and where racial tensions continue to simmer.

The hearing was halted briefly after a man lunged at Gendron, who was sitting at a table in the courtroom with his attorneys, as a woman named Barbara Massey, whose sister was one of those killed in the attack, delivered a victim impact statement.

As Ms Massey screamed at Gendron, the man stood up and went behind her, then pushed her aside and took several running steps toward Gendron before police and attorneys caught him.

Officers grabbed Gendron and rushed him out of the courtroom as the man who rushed at him was surrounded by police officers and led out. The man's identity was not immediately known.

The hearing resumed moments afterwards.

New York state no longer uses the death penalty. Gendron still could receive a death sentence if convicted of pending federal hate crime and firearms charges to which he has pleaded not guilty. Gendron was 18 at the time of the attack.

The gunman streamed live video of the attack to the social media platform Twitch after posting a racist screed online detailing his inspiration from other racially motivated mass killings, authorities said.

Ten people were killed in the fatal shooting in May of last year

Gendron was the first defendant in New York to be charged with a domestic act of terrorism motivated by hate in the first degree under a state law enacted in 2020.

Prosecutors say the gunman targeted a Tops Friendly Markets supermarket in a black neighbourhood of Buffalo, about 320km away from his home in Conklin, New York, intending to kill as many black people as he could with an assault weapon. In addition to the ten people who were killed, three others were wounded.

The victims ranged in age from 20 to 86 and included staff, patrons and community advocates. Two of the survivors are white, officials said.

In addition to state charges, Gendron faces 27 federal charges. His lawyers have sought a plea deal on the federal charges in an effort to avoid a possible death sentence. The US Justice Department has not disclosed what punishment it would seek if Gendron is convicted.

The Buffalo attack occurred just ten days before another mass shooting that killed 19 children and two teachers at an elementary school in Uvalde, Texas.

The latest US mass shooting occurred on Monday when a gunman killed three Michigan State University students and wounded five others before taking his own life.