The results reflected disillusionment with the country’s two establishment parties, the center-left Social Democratic Party and the conservative People’s Party. Those parties have dominated Austrian politics for decades, largely by governing together in a so-called grand coalition.

Bickering between them, over issues like taxes, education and pension reform, has eroded popular support over the past decade. The arrival of tens of thousands of migrants last summer, and the government’s decision to open Austria’s borders as Germany did, accelerated the slide.

Although many migrants simply passed through Austria, an Alpine nation of 8.4 million, on their way to Germany or Sweden, about 90,000 decided to remain in the country and apply for asylum. Responding to fears that emerged last fall, when local elections in Vienna reflected a surge in popularity for the Freedom Party, the government passed legislation in January to limit the number of people who could enter the country to 37,500 refugees and took steps to tighten the borders.

The move seemed to do little to reassure voters, who appeared to respond to Mr. Hofer’s call to strengthen the country’s borders and its army, limit benefits for immigrants and favor Austrians in the job market.

Sunday’s result was the best ever for the Freedom Party, which briefly entered the government in 2000, setting off an international outcry and earning the country sanctions from the European Union.