Collectively, the moves reinforce efforts by Mr. Orban to create a more illiberal and homogeneous society since regaining power in 2010. He has undermined the country’s checks and balances, gamed the electoral system, appointed loyalists to key positions in the judiciary, and eroded the independence of the news media.

To maintain public support for these measures, he has presented himself as the country’s only competent bulwark against external threats like migrants, Mr. Soros and the European Union, whose officials provide Hungary with crucial subsidies but who have been critical of his governance.

Although few migrants have tried to enter Hungary since the peak of the European migration crisis in 2015, Mr. Orban’s influence over most Hungarian media outlets has helped him convince many voters that migration remains a persistent challenge to the fabric of Hungarian society — giving him a mandate to enforce anti-migrant measures.

The “Stop Soros” legislation on aiding migrants has been condemned by global agencies and rights groups, including, among others, the United Nations, which also criticized Mr. Orban for his efforts to crack down on the homeless within the same legislative package, and Amnesty International.

“It is a bitter irony that as the world marks World Refugee Day, the Hungarian Parliament voted today to introduce a law that targets organizations and individuals who support asylum-seekers, refugees and migrants,” said Amnesty International’s Europe director, Gauri van Gulik.

“Criminalizing essential and legitimate human rights work is a brazen attack on people seeking safe haven from persecution and those who carry out admirable work to help them,” she said. “It is a new low point in an intensifying crackdown on civil society and it is something we will resist every step of the way.”

Patrick Gaspard, president of Mr. Soros’s Open Society Foundations, said: “Migration is clearly being used by the Hungarian government as a political diversion. The ultimate objective is to intimidate civil society and muzzle independent critics, including those who receive some of their funding from Open Society. We will continue to fund their important work at this difficult time, and do what we can to support Hungary’s courageous rights defenders.”