A German court has convicted a retired autoworker of being an accessory to the murder of thousands of people at a Nazi death camp where he worked as a guard decades ago.

John Demjanjuk was found guilty of 28,060 counts of accessory to murder, for which he has been sentenced to serve five years in prison.

Presiding Judge Ralph Alt said the 91-year-old Demjanjuk had been a piece of the Nazis' "machinery of destruction" during the Second World War.

However the same judge ordered Demjanjuk's release on Thursday, pending an appeal of his conviction.

Alt said that Demjanjuk has no opportunity to flee Germany as he is currently stateless, having lost his American citizenship years ago.

It could take six months or more for an appeal verdict to come in Demjanjuk's case.

Thursday's verdict against Demjanjuk came after a lengthy trial, in which the defendant denied having worked for the Nazis as a prison guard.

But the judge ruled Demjanjuk had in fact served as a guard at the Sobibor camp in Nazi-occupied Poland at the height of the war.

"The court is convinced that the defendant … served as a guard at Sobibor from 27 March 1943 to mid September 1943," the judge said Thursday, at the closing of the trial.

Demjanjuk was also convicted in the absence of any evidence that he committed any crime.

Instead, the prosecution was based on the theory that if Demjanjuk was present in the camp, he was a participant in the killings that occurred there. His trial was the first time that such a legal argument has been made in German courts.

Efraim Zuroff, the chief Nazi hunter at the Simon Wiesenthal Center, said the conviction was "a very important victory for justice."

In a telephone interview from Jerusalem, Zuroff told The Associated Press that "the verdict sends a very powerful message that, even many years after the crimes of the Holocaust the perpetrators can be brought to justice."

Zuroff said that he hoped Demjanjuk's conviction "will pave the way for additional prosecutions in Germany."

Rudolf Salomon Cortissos, the son of a woman who was gassed at Sobibor, wiped tears from his eyes when the verdict was read out.

"It's very emotional -- it doesn't happen every day," said Cortissos, who was happy with the verdict and its sentence.

"For me it is satisfying," he said.

ID card key to prosecution

A key piece of evidence in the long-running case was an SS-identity card that allegedly shows a picture of a young Demjanjuk and indicates that he trained at the SS Trawniki camp and was posted to Sobibor.

While experts testified that the identity card appears genuine, the defence claims it is a fake piece of identification produced by the Soviet KGB.

Years ago, Demjanjuk stood trial in Israel on allegations that he was actually "Ivan the Terrible," a notorious prison guard at the Treblinka extermination camp. He was convicted and sentenced to death, but later released after an Israeli court said the evidence showed he was a victim of mistaken identity.

Demjanjuk's view is that he was actually a victim of the Nazis. He says he fought for the Soviets and was captured and held as a prisoner of war by the Germans, before joining the Vlasov army -- an anti-communist force of Soviet POWs and Germans that fought against the Soviets in the dying months of the Second World War.

But prosecutors said the evidence shows that Demjanjuk actually agreed to serve in the German SS and that he was posted to work at the Sobibor camp.

Demjanjuk lived in the United States after the war ended and worked for many years as an autoworker in Ohio.

A timeline of Demjanjuk's life published by the Cleveland Plain Dealer indicates that he became a U.S. citizen in 1958.

The U.S. Justice Department attempted to revoke Demjanjuk's citizenship in 1977, alleging that he hid his past as a Nazi death camp guard.

It was revoked in 1981, but restored in 1998 after his conviction in Israel was overturned.

Demjanjuk would remain a U.S. citizen until 2002, when his citizenship was stripped from him for a second time.

In 2005, a U.S. immigration judge ruled that Demjanjuk could be deported to Germany, Poland or Ukraine.

Two years ago, Munich prosecutors issued a warrant for his arrest and he was deported to Germany in May 2009.

At the time of his deportation in 2009, Demjanjuk was the No. 1 wanted Nazi by the Simon Wiesenthal Center.

With files from The Associated Press