The controversial director made the comments during an unusual press conference for his movie Melancholia at the Cannes Film Festival.
Asked about his German roots, von Trier said: "I wanted to be a Jew and then I found out I was really a Nazi, because my family was German. Which also gave me some pleasure.
"What can I say? I understand Hitler. I think he did some wrong things, yes absolutely, but I can see him sitting in his bunker at the end... I think I understand the man. He's not what you would call a good guy. But I understand much about him and I sympathise with him a little bit."
He continued: "Come on, I'm not for the Second World War - and I'm not against Jews... [Jewish Danish director] Susanne Bier is... no, not even Susanne Bier! That was also a joke.
"I am of course very much for Jews! No, not too much because Israel is a pain in the ass. How can I get out of this sentence?!?!?!"
Von Trier added: "I'm very much for Speer - Albert Speer I liked. He was also maybe [not] one of God's best children, but he had some talent that was possible for him to use during... okay, I'm a Nazi!"
Asked if he could make a film on a grander scale than Melancholia, von Trier quipped: "On a grander scale? Yeah, that's what we Nazis really like. We have a tendency to try to do things on a greater scale. Maybe you could persuade me into... The Final Solution - with journalists."
Von Trier also suggested that his next film will be a four-hour hardcore pornography movie starring Kirsten Dunst, Charlotte Gainsbourg and Tobey Maguire.
> Lars von Trier talks Hitler, porn and Melancholia
> Melancholia review
> Cannes Film Festival complete coverage
Watch the Melancholia trailer below: