A British man who planned a neo-Nazi-inspired machete attack on a gay pride event has been sentenced to an indefinite stay in a psychiatric hospital.

Ethan Stables was arrested in June 2017 as he walked toward a pub in his hometown of Barrow-in-Furness, northwest England, on what prosecutors said was a reconnaissance trip. Police found an ax, a machete and a swastika flag at his home.

Prosecutors said Stables had posted on Facebook that he wanted to "slaughter every single one of the gay bastards."

Defense lawyers said the 20-year-old, who has an autism spectrum disorder, had been brainwashed by right-wing extremists. But he was convicted in February of preparing an act of terrorism.

Passing sentence Wednesday, Judge Peter Collier said Stables posed "a very real risk to the public."