MUNICH  — Retired U.S. autoworker John Demjanjuk was convicted of thousands of counts of acting as an accessory to murder at a Nazi death camp and sentenced on Thursday to five years in prison — closing one chapter in a decades-long legal battle.

Demjanjuk was charged with 28,060 counts of being an accessory to murder, one for each person who died during the time he was accused of being a guard at the Sobibor camp in Nazi-occupied Poland. There was no evidence he committed a specific crime. The prosecution was based on the theory that if Demjanjuk was at the camp, he was a participant in the killing — the first time such a legal argument has been made in German courts.

Presiding Judge Ralph Alt said the 91-year-old was a piece of the Nazis’ “machinery of destruction.”

“The court is convinced that the defendant … served as a guard at Sobibor from 27 March 1943 to mid September 1943,” Alt said, closing a trial that has lasted nearly 18 months.

Demjanjuk sat in a wheelchair in front of the judges as they announced their verdict, but showed no reaction. Earlier Thursday, he had declined the opportunity to make a final statement to the court.

It was not immediately how much credit the native of Ukraine he would get for time already served.

The verdict will not entirely end more than 30 years of legal wrangling. The defense has pledged to appeal any German conviction, and legal proceedings continue in the United States.

The Simon Wiesenthal Center’s chief Nazi hunter, Efraim Zuroff, called the conviction “a very important victory for justice.”

“The verdict sends a very powerful message that, even many years after the crimes of the Holocaust the perpetrators can be brought to justice,” he said by telephone from Jerusalem. “We’re hopeful that this verdict will pave the way for additional prosecutions in Germany.”

In the 1980s, Demjanjuk stood trial in Israel after he was accused of being the notoriously brutal guard “Ivan the Terrible” at the Treblinka extermination camp. He was convicted, sentenced to death — then freed when an Israeli court overturned the ruling, saying the evidence showed he was the victim of mistaken identity.

Demjanjuk maintains he was a victim of the Nazis — first wounded as a Soviet soldier fighting German forces, then captured and held as a prisoner of war under brutal conditions before joining the Vlasov Army, a force of anti-communist Soviet POWs and others was formed to fight with the Germans against the Soviets in the final months of the war.

But prosecutors said that after his capture, the evidence shows Demjanjuk agreed to serve the German SS and was posted to Sobibor in Nazi-occupied Poland.

Demjanjuk was accused of having served as a “Wachmann,” a guard, the lowest rank of the “Hilfswillige” volunteers who were subordinate to German SS men.

Integral to the prosecution’s case was an SS identity card that allegedly shows a picture of a young Demjanjuk, and indicates he trained at the SS Trawniki camp and was posted to Sobibor.

Though court experts said the card appears genuine, the defense maintains it is a fake produced by the Soviet KGB.

The U.S. Department of Justice’s Office of Special Investigations also has said the card is genuine, but documents unearthed by The Associated Press indicate that the FBI at one time had doubts similar to those aired by Demjanjuk’s defense about the evidence — though the material was never turned over to them.

In a 1985 report, the FBI’s Cleveland, Ohio, field office concluded that: “Justice is ill-served in the prosecution of an American citizen on evidence which is not only normally inadmissible in a court of law, but based on evidence and allegations quite likely fabricated by the KGB.”

The revelation has led to new court action in the U.S., with a District Court judge in Cleveland on Tuesday agreeing to appoint a public defender to represent Demjanjuk there, raising the prospect of renewing the decades-old case.