The suspect in an attack on a German synagogue that left two people dead has reportedly admitted carrying out the shooting.

The German, identified by prosecutors as Stephan B, was ordered to be held in custody pending formal charges at a closed-door hearing before a judge on Thursday night.

He is suspected of two counts of murder and seven of attempted murder over the attack in the city of Halle.

Germany Shooting
Dozens of floral tributes have been left at the scene in the city of Halle (Jens Meyer/AP)

Two people outside the synagogue were shot dead by the attacker after he failed to gain entry to the building.

News agency dpa reported the man admitted to the crime and a right-wing extremist motive, and federal prosecutors say he testified for several hours.

His lawyer, Hans-Dieter Weber, told broadcaster Suedwestrundfunk on Friday “it would be pointless to dispute anything, and he didn’t do that”.

The attack happened on Yom Kippur, Judaism’s holiest day, and was broadcast live on a popular streaming site.