GENEVA — A nationalist party rode an anti-immigrant wave Sunday to the best showing of any party in parliamentary elections since World War I, while the Greens made gains by appealing to environmental concerns, according to projections.

In one of the most bitter political campaigns in memory in this usually tolerant Alpine nation, the Swiss People’s Party called for a law to throw out entire immigrant families if a child violates national laws.

The party gained seven parliamentary seats in the 200-seat lower house of parliament, while the Green party added five, according to projections from widely respected experts for the state-owned SRG television and radio networks, which base forecasts on voting returns.

The Social Democrats, the second-largest party, were the big losers, dropping nine seats.

Switzerland’s population of 7.5 million includes about 1.6 million foreigners, including many workers from southern Europe and refugees from the Balkan wars of the 1990s.

The People’s Party claims foreigners are responsible for much of the crime in the country.

Party posters featuring white sheep kicking out a black sheep sparked outrage blamed in part for a riot two weeks before the election — a rare show of violence against a political party.

The People’s Party will now turn its attention to reducing crime, cutting taxes and keeping Switzerland out of the European Union, said its president, Ueli Maurer.

“I’m very happy,” he said. “The idea of EU accession should at last get out of everyone’s heads.”

A Swiss bid for EU membership filed in the 1990s has been suspended by the Cabinet in recent years. The People’s Party, which campaigns for strict adherence to Swiss traditions of neutrality and independence, wants the application withdrawn completely.

The party became the largest in Switzerland four years ago under the leadership of charismatic billionaire Christoph Blocher.

It was projected to win about 28.8 percent of the vote, or 62 seats in the lower house — the largest share of seats any party has won since Switzerland’s proportional voting system began in 1919.

Sharing powerAlthough the party will have more leverage in the formation of the next government, Maurer said it would still share power with the three other major parties. Those include the Radical Democrats and the Christian Democrats, which each won a projected 31 seats.

The Social Democrats, which focused its campaign on rejecting the People’s Party proposal, won a projected 19.3 percent of the vote and fell back to 43 seats.

“I’m very disappointed that the Swiss people fell for such an election campaign by the People’s Party,” said Matthias Weller, a 30-year-old physician in Zurich. “People don’t realize that their campaign is just made with money. They don’t have a program except for cutting government spending.”

On the left the Green Party was projected to win 9.6 percent of the vote, increasing its seats in parliament to 19.

“I’m very happy with the result,” said Ruth Genner, president of the Greens. But she noted that the party appeared to be just short of their goal to be asked to join the four major parties in the Cabinet.

“We missed the 10 percent limit very slightly which I regret a little bit,” she said.

Climate changeThe Greens campaigned heavily on combatting climate change, including proposals for a ban on air shows in Switzerland and imposition of a jet fuel tax to counter the emissions of greenhouse gases from airplanes.

Switzerland, which has been losing glaciers in its beloved Alps to the melting effects of warmer weather in recent years, is particularly concerned about climate change.

Nearly 4.8 million Swiss voters were eligible to cast ballots Sunday for the two-chamber National Assembly: the National Council and the 46-seat Council of States.

Results for the upper chamber were incomplete because a runoff will be held Nov. 25. The full assembly will then determine the makeup of the seven-member Cabinet on Dec. 12.