Police said Payton Gendron shot 11 Black and two white victims before surrendering to authorities in a rampage he broadcast live on the streaming platform Twitch.
Later, he appeared before a judge in a paper medical gown and was arraigned on a murder charge.
"It is my sincere hope that this individual, this white supremacist who just perpetrated a hate crime on an innocent community, will spend the rest of his days behind bars. And heaven help him in the next world as well," said Gov. Kathy Hochul, speaking near the scene of the attack. ""It strikes us in our very hearts to know that there is such evil that lurks out there."
WATCH | Governor Kathy Hochul delivers remarks from Bufffalo
Hochul plans to attend church services Sunday morning in the predominately African American neighborhood where the shooting took place.
The massacre sent shockwaves through an unsettled nation gripped with racial tensions, gun violence and a spate of hate crimes. In the day prior to the shooting, Dallas police said they were investigating a series of shootings in Koreatown as hate crimes. The Buffalo attack came just one month after another mass shooting on a Brooklyn subway train wounded 10 people.
The suspected gunman in Saturday's attack on Tops Friendly Market was identified as Payton Gendron, of Conklin, New York, about 200 miles southeast of Buffalo.
Investigators believe that Gendron posted an 180-page document on the internet before the mass shooting, which included a detailed plan for the attack and his support for several mass murderers.
It wasn't immediately clear why Payton had traveled to Buffalo and that particular grocery store. A clip apparently from his Twitch feed, posted on social media, showed Gendron arriving at the supermarket in his car.
The gunman shot four people outside the store, three fatally, said Buffalo Police Commissioner Joseph Gramaglia. Inside the store, security guard Aaron Salter, a retired Buffalo police officer, fired multiple shots. A bullet hit the gunman's bulletproof armor but had no effect, Gramaglia said.
The gunman then killed the guard, the commissioner said, then stalked through the store shooting other victims.
Police entered the store and confronted the gunman in the vestibule. He put his rifle to his own neck, but two officers talked him into dropping the gun, Gramaglia said.
"This is the worst nightmare that any community can face, and we are hurting and we are seething right now," Buffalo Mayor Byron Brown said at the news conference. "The depth of pain that families are feeling and that all of us are feeling right now cannot even be explained."
Twitch said in a statement that it ended Gendron's transmission "less than two minutes after the violence started."
A law enforcement official told The Associated Press that investigators were looking into whether he had posted a manifesto online. The official was not permitted to speak publicly on the matter and did so on the condition of anonymity.
Buffalo police declined to comment on the document, circulated widely online, that purports to outline the attacker's racist, anti-immigrant and antisemitic beliefs, including a desire to drive all people not of European descent from the U.S. It said he drew inspiration the man who killed 51 people at two mosques in Christchurch, New Zealand, in 2019.
WATCH | Officials hold update on Buffalo shooting
At the earlier news briefing, Erie County Sheriff John Garcia pointedly called the shooting a hate crime.
"This was pure evil. It was (a) straight up racially motivated hate crime from somebody outside of our community, outside of the City of Good Neighbors ... coming into our community and trying to inflict that evil upon us," Garcia said.
Among the dead was Ruth Whitfield, the 86-year-old mother of a retired Buffalo fire commissioner.
"My mother was a mother to the motherless. She was a blessing to all of us," former Fire Commissioner Garnell Whitfield told the Buffalo News.
Witnesses Braedyn Kephart and Shane Hill, both 20, pulled into the parking lot just as the shooter was exiting.
"He was standing there with the gun to his chin. We were like what the heck is going on? Why does this kid have a gun to his face?" Kephart said. He dropped to his knees. "He ripped off his helmet, dropped his gun, and was tackled by the police."
Officials said the rifle Gendron used in the attack was purchased legally but that the magazines he used for ammunition were not allowed to be sold in New York.
President Joe Biden in a statement said he and the first lady were praying for the victims and their families.
"We still need to learn more about the motivation for today's shooting as law enforcement does its work, but we don't need anything else to state a clear moral truth: A racially motivated hate crime is abhorrent to the very fabric of this nation," he said. "Any act of domestic terrorism, including an act perpetrated in the name of a repugnant white nationalist ideology, is antithetical to everything we stand for in America."
Tops Friendly Markets released a statement saying, "We are shocked and deeply saddened by this senseless act of violence and our thoughts and prayers are with the victims and their families."
The shooting came little more than a year after a March 2021 attack at a King Soopers grocery in Boulder, Colorado, that killed 10 people. Investigators have not released any information about why they believe the man charged in that attack targeted the supermarket.
NAACP President Derrick Johnson issued a statement in which he called the Buffalo shooting "absolutely devastating."
"Hate and racism have no place in America," he said.
The Rev. Al Sharpton called on the White House to convene a meeting with Black, Jewish and Asian leaders to demonstrate a federal commitment to combating hate crimes.
More than two hours after the shooting, Erica Pugh-Mathews was waiting outside the store, behind police tape.
"We would like to know the status of my aunt, my mother's sister. She was in there with her fiancé, they separated and went to different aisles," she said. "A bullet barely missed him. He was able to hide in a freezer but he was not able to get to my aunt and does not know where she is. We just would like word either way if she's OK."
Associated Press reporters Eric Tucker in Washington and Aaron Morrison in New York City contributed to this report. Balsamo reported from Washington and Collins reported from Hartford, Connecticut.