Hungarian lawmakers have rejected constitutional amendments that would have banned the settlement of migrants in the country.
The proposal won only 131 votes in the 199-seat parliament, just short of the necessary two-thirds majority of 133.
The parliamentary vote on November 8 was the second major setback for Hungarian Prime Minister Victor Orban, a ring-wing and antimigrant populist.
In October, Hungarians voted in a referendum to reject a European Union migrant quota, but a low turnout made the vote invalid.
Orban's efforts to pass the legislation came in reaction to a EU-set migrant quota agreed in 2015 that would relocate 160,000 migrants across the bloc.
Under the quota, Hungary would receive 1,294 migrants.