In the last Vienna elections, in 2010, the Freedom Party vaulted to more than 25 percent of the vote, a gain of over 10 percentage points. By this summer, opinion polls suggested, the far-right party had pulled almost level with the Social Democrats, who got 44 percent in 2010. Both now hover just above 30 percent.

The causes are manifold, including unemployment that has risen to more than 10 percent and dissatisfaction with the longtime mayor, Michael Häupl. His working-class base is eroding; others fault him for failing to end cozy patronage systems that favor the powerful over the poor.

What everyone is wondering now is what effect the migrants will have.

Thousands of Viennese have greeted tens of thousands of refugees arriving from Hungary this month. The national government, which had long flailed on the issue, found a firm voice and strongly criticized Budapest for putting refugees on trains that led them not west to Austria, but to a camp in Hungary. This, said Chancellor Werner Faymann, a Social Democrat, “brings up memories of our Continent’s darkest period.”

Like Germany, Austria loudly advocates asylum for refugees. Its projected total of applicants, many from the Middle East, is 80,000 this year, meaning that, like Germany’s, its population may grow by 1 percent.

But its image as a caretaker for waves of refugees over decades — Hungarians, Czechs, Slovaks, Poles, East Germans and former Yugoslavs escaping Communism or war — suffered this summer. Its main refugee center at Traiskirchen was found to be squalid, with inadequate medical care and more than 1,000 people sleeping in the open. When the authorities refused to admit a group from Doctors Without Borders, leftists seethed.

When a reporter visited the camp in late August, conditions had improved, although tents still provided shelter for 1,200 of the 3,000 people there. Austrians shocked by the conditions had brought so many clothes, toys and other goods that containers overflowed with rejects.