Hamburg has become the first German city to pass a law allowing the seizure of empty commercial properties in order to house migrants.
The influx of migrants has put pressure on the authorities of the northern city to find accommodation. Some migrants are sleeping rough outdoors.
Hamburg's law takes effect next week.
In a separate development, prosecutors filed charges of inciting racial hatred against a co-founder of the anti-Islamic Pegida movement.
The prosecutors in the eastern city of Dresden said they acted after Lutz Bachmann had on Facebook described asylum seekers "trash" and "animals".
Pegida (Patriotic Europeans Against the Islamisation of the West) members have staged a number of rallies in recent months, attracting tens of thousands of people.
Meanwhile, a new survey by broadcaster ARD said 51% of people admitted the influx of migrants scared them. It suggests a four-year low in Chancellor Angela Merkel's popularity.
She has said Germany can accommodate migrants who have genuinely fled war or persecution - a humanitarian gesture towards the many thousands risking their lives to reach Europe this year.
But many politicians - including her conservative Bavarian CSU allies and various EU partners - have criticised the open-door policy.
Hamburg's new law is described as a temporary, emergency measure. Owners of empty commercial properties will be compensated. The law does not include residential properties.
But the conservative opposition in the city, in the north of Germany, condemned the move.
The authorities in Bremen, a city just west of Hamburg, are considering passing a similar law.
Germany expects to host at least 800,000 asylum seekers this year - about four times the number it had last year.
Many are from war-torn Syria, Iraq and Afghanistan. But the thousands arriving also include asylum seekers from Kosovo, Albania and other Balkan countries, whose claims are usually rejected.
On Thursday more than 200 migrants fought each other in a mass brawl at a reception centre in Hamburg-Bergedorf. Police said Syrians and Afghans were involved in the latest clash.
Similar fights have erupted at some other migrant centres in Germany. A bigger brawl took place near Kassel, in central Germany, at the end of September.
In Berlin, Munich, Hamburg and elsewhere the authorities have erected tented camps for migrants - but with winter approaching they are deemed too basic as communal housing.
There is hardly any accommodation left in Hamburg for migrants, who are entering the city at a rate of about 500 daily, ARD television reports.
The Hamburg region's leftist government - a coalition of Greens, Social Democrats (SPD) and Die Linke - says the new law will be in force until March 2017.
Confiscation will only take place if the property owner refuses to hand it over willingly in exchange for compensation.
In the Brandenburg region, in eastern Germany, the authorities have halted the demolition of old social housing blocks. Instead they will be refurbished to provide 4,000 flats for migrants, the daily Die Zeit reports.
Meanwhile Franconia, in north Bavaria, plans to build cheap modular units to house migrants for 10 years, after which they will be rented out as social housing for locals.