A French lawmaker who was allegedly recorded saying that Hitler "did not kill enough" Roma has resigned from his party, just days after investigators opened a criminal probe into his comment.

The centrist Union of Democrats and Independents said Gilles Bourdouleix had resigned in a letter sent to the party headquarters on Wednesday, hours before executive committee members were due to meet to discuss his fate.

Bourdouleix reportedly muttered the remark on Sunday as he confronted members of the travelling community who had illegally set up camp in the western town of Cholet, where he is mayor.

According to a recording posted on the site of regional daily Courrier de l'Ouest, he is heard saying "maybe Hitler did not kill enough," after the Roma -- sometimes known as gypsies -- had reportedly given him the Nazi salute.

His comment sparked huge outrage, with Interior Minister Manuel Valls calling for the lawmaker to be "severely punished" for the comments.

Yves Gambert, a local prosecutor, said his office had opened a preliminary investigation into the remarks on charges of "defending crimes against humanity".

Bourdouleix faces up to five years in prison and a 45,000-euro ($60,000) fine if convicted on the charge.

Prosecutors have also ordered that the recording of the remark be analysed to see if it was altered.

Bourdouleix has said his comments were taken out of context and alleged the recording was tampered with.

The lawmaker has made controversial remarks about Roma in the past, including in November 2010, when he threatened to drive a truck through one of their caravan camps, and last November, when he said France was facing a "new invasion" from the community.

Confrontations between French authorities and Roma erupt frequently.

France has a policy of systematically dismantling illegal camps and repatriating Roma of Bulgarian and Romanian nationality -- a policy whose legality has been questioned by the European Union, the United Nations' human rights arm and other watchdogs.

The Roma, a nomadic people whose ancestors left India centuries ago, have long suffered from discrimination and are frequently accused of carrying out petty crimes.

They were killed in their hundreds of thousands by the Nazis during the Second World War, alongside Jews and homosexuals.