(This March 20 story was corrected in the second paragraph to make clear Freedom Party did not make huge gains)
By Anthony Deutsch and Thomas Escritt
AMSTERDAM (Reuters) - A parliamentarian for the Dutch hard-right Freedom Party resigned from the party on Thursday amid uproar over the way leader Geert Wilders led supporters in racist chants against Moroccans during an election night rally.
Wilders' eurosceptic, anti-Islam Freedom Party failed to make the huge gains it had expected in Wednesday's municipal elections, which it contested in two cities. It held onto its top position in the city of Almere and second place in The Hague, although it slipped slightly in percentage terms.
Polls suggest it will become the largest Dutch party in the European assembly in elections in May.
On Wednesday night in The Hague, Wilders asked a crowd of supporters: "Do you want more or fewer Moroccans in this city?"
They chanted "Fewer! Fewer! Fewer!"
Wilders smiled and responded "I'll take care of that."
Roland van Vliet, who will remain in parliament as an independent, said Wilders' views on Muslims were becoming more extreme, moving from criticism of Islamic militancy to claims that statistics showed Moroccans committed a disproportionately high number of crimes.
"And now he's talking about the entire group," van Vliet said, adding that it was a relief to be quitting the party.
The campaign for the local elections was dominated by Wilders' anti-Moroccan rhetoric. But Wednesday evening's remarks triggered indignation, with prosecutors saying they had received more than 100 requests to investigate him for hate speech.
Politicians and immigrant groups denounced his remarks, while the deputy editor-in-chief of terrestrial broadcaster RTL broke a long-standing tradition of editorial neutrality by penning an open letter telling Wilders: "Shame on you."
The Association for Dutch Moroccans, which represents 368,000 people of Moroccan origin in the Netherlands, said on Thursday it would file charges of discrimination against Wilders and appealed to others to do the same.
Wilders has a history of statements that upset Muslims and Eastern European migrant workers. He was prosecuted for hate crimes and discrimination for calling Islam a fascist ideology in 2007 and was acquitted in June 2011.
Ahmed Charifi, the association's chairman, said Wilders had crossed a legal boundary by targeting a specific group of people.
"This has a huge impact on the community and I hope a judge will see that. He crossed a line, and to be honest it's a bit frightening," he said.
"It raises images of a man in the 1930s with a moustache in front of a microphone," Charifi said, referring to Adolf Hitler.
Prime Minister Mark Rutte of the Liberal party said the incident left "a foul taste in my mouth."
"All those people in the country who want to make a positive contribution, I do not care where they come from. All that matters is their future," he said on Dutch television.
It was the second time in a week remarks by Wilders have caused a public backlash.
He told supporters in The Hague last week they should vote "for a city with fewer problems, and if it's at all possible, a few fewer Moroccans."
In neighboring Belgium, Flemish separatist politician Filip Dewinter, whose far-right Vlaams Belang party has similar views on immigration to Wilders, endorsed his remarks. "I hope he repeats them," he told news portal deredactie.be.
(Editing by Geert De Clercq and Angus MacSwan; Editing by Hugh Lawson)