A Swedish cabinet minister of Turkish origin who compared Israel to Nazi Germany and was photographed with Turkish ultranationalists resigned on Monday, Swedish Prime Minister Stefan Lofven announced.

"Mehmet Kaplan has submitted his resignation and I have accepted it," Lofven told reporters, nonetheless praising the outgoing housing minister's "humanistic and democratic values."

Kaplan, a member of the junior coalition partner Green Party, told reporters he was opposed to "all forms of extremism" and stressed his dedication to "human rights, democracy and dialogue."

The 44-year-old had been in hot water since the weekend when media published video footage of him making controversial remarks about the Jewish state.

During a March 2009 debate organized by a Somali organization, Kaplan, who was a member of parliament at the time, said there were "similarities" between the persecution of Jews by Nazi Germany during the 1930s and the everyday lives of Arabs living in the Palestinian Authority-ruled areas.

Israel's ambassador to Sweden, Isaac Bachman, branded the remarks as "deeply anti-Semitic."

"I have on several occasions criticized the actions of the state of Israel severely, but I am clearly not anti-Semitic... My criticism of Israel does not make me less critical of the anti-Semitism that exists in Sweden," Kaplan wrote in a comment published on the website of daily Expressen after his resignation was announced.

Last week, media had published photos of Kaplan attending a July 2015 dinner in Sweden with Turkish ultranationalists, which sparked strong reactions from the opposition, media, and the public.

Among those attending the dinner was Ilhan Senturk, the Swedish head of the ultranationalist "Grey Wolves" organization known for political violence in the 1970s and 1980s.

Also present was Barbaros Leyani, the former vice-president of the Turkish National Association of Sweden who was forced to resign after calling for the murder of "Armenian dogs" during a demonstration in Stockholm in April.

Kaplan, who was born in Turkey and moved to Sweden when he was eight, also came under fire from media and political opponents for his ties to Islamic organizations, especially Milli Gorus which is suspected of promoting religious fundamentalism.

He acknowledged those ties, but "that doesn't mean I agree with them on everything," he told Swedish television.

Opposition leader Anna Kinberg Batra of the conservative Moderates criticized Prime Minister Lofven, a Social Democrat, for "being passive and slow" to react to the controversy.

AFP contributed to this report