Lars Von Trier is known for being unpredictable, quixotic, puckish and deliberately provocative. But even he over-leaped his high standards of eccentricity as he spoke before the Cannes premiere of Melancholia, his latest film, announcing “I’m a Nazi” and that he “understands Hitler”.

He also jokingly claimed he was writing a four-hour-long hardcore porn film featuring Melancholia stars Charlotte Gainsbourg and Kirsten Dunst. It would, he said, contain “a lot of very, very unpleasant sex”.

The nazism remarks, which were jestingly made in response to a question about his German roots, would probably spell career suicide if uttered outside the rarefied atmosphere of the Cannes film festival – and indeed may yet.

As Melancholia’s star Dunst looked on ashen-faced – at one point attempting to halt his flow with a restraining arm on his shoulder – he said: “I thought I was a Jew for a long time and was very happy being a Jew ... Then it turned out that I was not a Jew ... I found out that I was really a Nazi which also gave me some pleasure.

“What can I say? I understand Hitler. He did some wrong things, absolutely, but I can see him sitting there in his bunker at the end ... I sympathise with him, yes, a little bit.”

Attempting to extricate himself from his self-dug grave, he added: “But come on, I am not for the second world war, and I am not against Jews. I am very much for Jews; well not too much because Israel is a pain in the ass. But still, how can I get out of this sentence ... OK I’m a Nazi.”

The organisers of the festival issued a statement saying they had been “disturbed” by the remarks, that he had apologised, and that the festival would never allow the event to become the forum for such pronouncements.

Von Trier issued his own statement: “If I have hurt someone this morning by the words I said, I sincerely apologise. I am not antisemitic or racially prejudiced in any way, nor am I a Nazi.”

The question that led to von Trier’s remarks came from the Times film critic, Kate Muir, about his German origins and the influence of the Gothic on his work.

Von Trier said “he let himself be egged on by a provocation”, the festival statement said.

In an another capricious riff, which Gainsbourg and Dunst watched in a state of what appeared to be nervous hilarity, Von Trier claimed Dunst had insisted she be filmed naked for a scene in Melancholia. “And now she wants more,” claimed the Danish director. “That’s how women are, and Charlotte is behind this. They want a really hardcore film this time, and I am doing my best.

“I said let’s have a lot of talking in it, and they said, ‘We don’t give a shit about the dialogue, we just want to have a lot of very very unpleasant sex,’ and that’s what I am writing right now.”

No one could accuse Melancholia of a lack of ambition. If Terrence Malick’s Tree of Life, which screened earlier in the festival, sets a family drama against the origins of the cosmos, then Von Trier’s Melancholia sets a family drama against the end of the world.

The film’s first screening was greeted with applause, but has already split its early viewers – though it seems likely that the film itself will be overshadowed by the director’s ill-advised public statements. In any case, Von Trier himself is apparently siding with Melancholia’s sternest critics. He said, “Maybe it’s crap. Of course I hope not, but there’s quite a big possibility that this might be really not worth seeing.”

He said that he felt he may have got carried away with the film’s high Germanic romanticism, with the first 10 minutes devoted to a series of visually arresting, apocalyptic tableaux set against the complete Prelude to Wagner’s Tristan und Isolde.

Of the mood of the film, he said: “Melancholia is a good title ... and melancholy is a quality that is in all art that I like, and I am sure it is part of all good art. It was the starting point of the film and the inspiration came from there. To be melancholic has to do with a longing, which is something a little special for this film.”