An Iraqi ex-soldier on Wednesday appeared before a Berlin court charged with war crimes.

Rami K. is accused of posing for photographs with the decapitated heads of two fighters from the so-called "Islamic State" (IS), before sharing the images online.

The 28-year-old came to Germany seeking refuge in 2015, the same year hundreds of thousands of Iraqis, Syrians and others did the same. He lived in the capital before being arrested last August.

The photos are believed to have been taken in March of 2015, while he was fighting in the Iraqi army against IS near the town of Tikrit, north of Baghdad.

K. has defended himself before the court, saying he was ordered by his superiors to pose with the heads. He told judges, via an interpreter, that "had I disobeyed the order, the punishment would have been execution."

Judges were showed the image of the accused in uniform with his arms outstretched, holding a head by the hair in each hand.

"I didn't feel comfortable in my skin," K. said. "I always had the feeling that it was wrong." He went to tell the court that after the incident he was unable to eat for a week before he eventually decided to quit the military.

Investigated in Germany

Police came across the photo on his Facebook profile in July 2016, after they confiscated his tablet as part of a separate charge against the 28-year-old. He was arrested the following month after prosecutors ruled that the photographs mocked and degraded the dead and was therefore liable for two counts of war crimes.

If found guilty, K. faces between 18 months and two years in prison. Three further hearings are scheduled before March 2, after which the court is expected to reach a decision.

Editor's note: Deutsche Welle follows the German press code, which stresses the importance of protecting the privacy of suspected criminals or victims and obliges us to refrain from revealing full names in such cases.

dm/se (AFP, dpa)