Lars von Trier brought the end of the world to the Cannes Film Festival — then the Danish director really shook things up, saying he sympathizes with Adolf Hitler, thinks Israel is a pain and plans to make a porn flick with Kirsten Dunst.

Von Trier’s remarks Wednesday stirred up reporters and sparked a swift response from festival organizers, who issued a statement saying they were “disturbed” and had called the Danish director in to explain himself.

Von Trier’s publicists later released a separate statement saying the director “sincerely apologize(d)” for the comments.

“I am not anti-Semitic or racially prejudiced in any way, nor am I a Nazi,” he is quoted as saying.

Von Trier made the incendiary comments at a news conference following the first screening of his latest film, apocalypse drama “Melancholia,” where he was flanked by its stars, including Dunst and Charlotte Gainsbourg.

Asked about his German heritage, von Trier launched into a rambling train of thoughts, starting with how he used to think he was a Jew and his disappointment when he learned he was not.

“I really wanted to be a Jew, and then I found out that I was really a Nazi, because, you know, my family was German,” von Trier said. “Which also gave me some pleasure. …

“What can I say? I understand Hitler, but I think he did some wrong things, yes, absolutely. But I can see him sitting in his bunker in the end,” von Trier said. “He’s not what you would call a good guy, but I understand much about him, and I sympathize with him a little bit. But come on, I’m not for the Second World War, and I’m not against Jews. …

“I am very much for Jews. No, not too much, because Israel is a pain in the ass.”

Von Trier then asked, “How can I get out of this sentence?”

Going on to say he liked Hitler aide Albert Speer, von Trier finally wrapped up with the wisecrack, “OK, I’m a Nazi.”

Afterward, von Trier told The Associated Press the remarks just spilled out without any forethought.

“I don’t have so much to say, so I kind of have to improvise a little and just to let the feelings I have kind of come out into words,” von Trier said. “This whole Nazi thing, I don’t know where it came from, but you spend a lot of time in Germany, you sometimes want to feel a little free and just talk about this (expletive), you know?”

Moshe Kantor, president of the European Jewish Congress, which is based in Paris, said the comments were an example of the growing phenomenon of what he called “respectable anti-Semitism.”

“Von Trier’s remarks serve as another reminder of the seeming comfort that anti-Semites feel expressing their prejudices in public gatherings,” Kantor said in a statement. “There must be consequences for these types of racist tirades, or it will just continue and escalate.”

Dunst, Gainsbourg and other “Melancholia” co-stars, including John Hurt and Stellan Skarsgard, sat stiff and stony-faced through most of von Trier’s comments. At one point, though, Dunst leaned over and whispered to von Trier, “Ohmy God, this is terrible.”

In an interview later, Dunst said von Trier felt embarrassed about the remarks.

“He likes to run his mouth,” Dunst said. “I think he dug himself in a deep hole today.”

Dunst has a nude scene in “Melancholia,” and von Trier joked that he now intends to do a porn film with her.

“Now she wants more. That’s how women are, and Charlotte is behind this. They want a really, really, really hardcore film this time, and I’m doing my best,” von Trier said, as Dunst and Gainsbourg chuckled uncomfortably beside him.

Von Trier has a long history of agitating Cannes crowds. His 2000 drama “Dancer in the Dark” won the festival’s top prize, the Palme d’Or, but the film sharply divided audiences, some loving it, some hating it.

Two years ago, his marital saga “Antichrist” aggravated many Cannes viewers with its torture-porn images, though the film went on to win the festival’s best-actress award for Gainsbourg.

Opening in U.S. theaters this fall, “Melancholia” casts Dunst as a woman in deep depression that turns her wedding day at the home of her sister (Gainsbourg) into a disaster. The story plays out against an end-of-the-world backdrop as a planet called Melancholia, which fittingly changes colors from blue to black, heads on a possible collision course with Earth.

The film also co-stars Kiefer Sutherland, Charlotte Rampling and Udo Kier.

“Melancholia” earned polite applause after a press screening but none of the sharp booing that sometimes greets troubling films at Cannes, von Trier’s among them. Some critics were underwhelmed by the family dynamic von Trier created but praised the film’s gorgeous visuals and emotional prologue.

Von Trier himself played critic on the film, saying there are things he likes about it but that some of the images look terrible to him.

“Maybe it’s crap,” von Trier joked. “Of course, I hope not. But there is quite a big possibility that this might be, you know, really not worth seeing.”

Copyright 2015 by Associated Press. All rights reserved.This material may not be published, broadcast, rewritten or redistributed.