At least 10 people were killed and three others injured as a gunman opened fire at a supermarket in New Yorks’s Buffalo city on Saturday, Reuters reported.

The shooter was identified as an 18-year-old white male named Payton S Gendron, according to The New York Times. He was taken into custody after he surrendered to the police.

The authorities said that 11 out of the total residents shot at were Black. They said that Gendron drove to Buffalo from his home in a New York county that was “hours away” for the attack.

Erie County sheriff John Garcia said that the attack was clearly racially motivated.

“This person was pure evil,” Garcia said during a news conference, according to Reuters. “It was a straight-up racially-motivated hate crime from somebody outside of our community.”

Police officials said that the shooter wore body armour and military-style clothing during the attack, according to The Associated Press.

“He exited his vehicle. He was very heavily armed. He had tactical gear,” city Police Commissioner Joseph Gramaglia said. “He had a camera through which he was live-streaming what he was doing.”

Gramaglia added that when the police entered the store and confronted the gunman in the vestibule, he attempted to shoot himself.

“At that point, the suspect put the gun to his own neck,” Gramaglia said, according to AP. “Buffalo police personnel – two patrol officers – talked the suspect into dropping the gun. He dropped the gun, took off some of his tactical gear, and surrendered at that point. And he was led outside, put in a police car.”

The 18-year-old had also posted a hate-filled manifesto online that included an account of detailed planning for the attack, The New York Times reported, citing an unidentified federal law enforcement official.

“His writings were also riddled with racist, anti-immigrant views arguing that white Americans are at risk of being replaced by people of colour,” the newspaper reported. “He wrote that he was inspired by the perpetrators of other white supremacist acts of violence.”

The gunman was produced before a court in New York where he pleaded not guilty to first-degree murder. The court ordered his arrest without bail.