Brazil has re-opened its northern border with Venezuela to those fleeing economic and political turmoil there, after briefly closing it.
The Supreme Court overturned an earlier order to shut the frontier until Brazil could put in place the right conditions to receive the huge influx of people.
Authorities in the state of Roraima in Brazil's Amazon region say some 500 Venezuelans cross the border every day.
The border was re-opened to Venezuelan migrants after a few hours on Monday.
"It is not justified to take the easy path to 'close the doors' because of difficulties in hosting refugees," Supreme Court justice Rosa Weber said in her ruling issued shortly before midnight.
The temporary order by a lower court judge stated that the border would remain open to Brazilians and other non-Venezuelans.
It was also to be open for Venezuelans returning north out of Brazil. Sea and air borders were unaffected by the ruling.
Many thousands of Venezuelans have fled into neighbouring countries, mainly Colombia and Brazil, in search of better economic conditions over the past three years.
An apparent assassination attempt on Venezuela's President Nicolás Maduro at the weekend has raised tensions in the country even further.
Most who have crossed the border to Brazil in recent months are living in appalling conditions on the streets of the Boa Vista, the impoverished state capital of Roraima, in the heart of the Amazon region.
For months, authorities in Roraima have been calling for the border to be shut. They say that public services have collapsed and that migration has brought about a sharp rise in crime.
Brazil's central government had opposed any border closure, saying that ordinary Venezuelans were suffering the consequences of a humanitarian crisis and that Brazil must continue to help.