BERLIN—A German man suspected of killing two people near a synagogue in the country’s east and streaming the assault online was arrested on Wednesday after what authorities said appeared to be an anti-Semitic attack by a far-right extremist.

Witnesses said they saw the suspect, armed with two guns and wearing a helmet with a camera on top, try and fail to gain access to a synagogue in the city of Halle, where some 60 worshipers, including 10 U.S. nationals, had gathered to celebrate Yom Kippur, the holiest day on the Jewish...