Swedish lawmakers overwhelmingly approved legislation on Tuesday to tighten regulations for asylum and family reunification in the Scandinavian country which had a record 163,000 asylum-seekers last year.

Under the new law, some asylum-seekers who were earlier automatically granted permanent residency will now get only temporary residence permits. The new legislation also has stricter restrictions on family reunification and harsher maintenance requirements.

The law will make Sweden's regulations among the tightest in Europe and was criticized by many, including the Red Cross and Save the Children, as being inhumane.

After Germany, Sweden was the top destination for asylum-seekers entering Europe last year. The Nordic country has been famous for its welcoming attitude to immigrants and generous welfare benefits, but since last year concerns have been growing that its welcome is reaching a limit.

Social Democratic Prime Minister Stefan Lofven's government was long a champion of open borders to refugees but reversed course and tightened controls in January, joining several other European Union members to help manage the flow of migrants.

Hundreds of people gathered outside Parliament to protest the law, which was passed in a 240-45 vote, with 64 absent or abstaining.

Carl Schlyter, a Green Party member who voted against his party and the government line, said he felt the criticism of the new measures by aid organizations had been so strong that he "just had to heed them."

"We need time to consider this and come up with a decision which is people-friendly and fully complies with Sweden's international commitments," he told state broadcaster SVT.

The temporary measures come into force on July 20 for an expected three-year period and will apply retroactively to migrants who have applied for asylum after Nov. 24, 2015.