A massive security operation, involving up to 10,000 police and soldiers, is under way along Hungary's southern border with Serbia, to keep out migrants and refugees.
The armed forces have been deployed to reinforce a 175km (110-mile) razor-wire fence erected last year on a border that is also a gateway to the European Union.
Until new regulations came into force on 5 July, an average of 130 people crossed the fence every day.
The new law allows the authorities to push back anyone caught inside Hungary within 8km of the fence, but in practice it seems to be applied to those caught far deeper into Hungary, as far as Budapest.
The push-backs usually happen at night, through gates built into the razor wire fence, or even over the wire.
The measures have caused growing backlogs on the Serbian side in daytime temperatures of up to 37C. More than 1,000 migrants are now waiting to enter Hungary, legally, through one of two "transit zones" at Horgos and Kelebia.
The conditions in the camp at Horgos are appalling. Most of the residents are Afghans, while Syrians and Iraqis are concentrated at Kelebia.
A long queue forms each morning for the two taps of running water which serve 850 people, including many women and children. There are now 12 toilets.
Another queue forms rapidly when a jeep from the Serbian Red Cross arrives with bread rolls. The UN refugee agency, the UNHCR, provides tins of tuna. People boil water for tea over small fires dug into the sandy earth. Some bake potatoes or sweet corn on the embers, or heat the tuna.
Shelter from the burning sun is offered by small tents and UNHCR blankets, tied together between poles cut from the undergrowth.
Last week a 10-year-old Afghan boy drowned while trying to wash in a pond nearby. His mother walks aimlessly through the camp with her other children, too sad to speak to anyone.
The UNHCR is mediating with the Serbian and Hungarian authorities about where to bury the dead boy.
The unofficial leader of the camp, 25-year-old Afghan doctor Hamid Joya, is besieged by people trying to find out what number they are on his list.
He negotiates with the Hungarian Office of Immigration and Nationality, which controls the steel turnstile into the transit zone, built right into the border fence. Each day 15 people are admitted - 14 from families, and one single male; and a similar number at the other transit zone at Kelebia.
"When the transit zones were first established we were told they could process 100 people a day," UNHCR spokesman Erno Simon told the BBC on a fact-finding visit to Horgos.
"We have been trying to persuade the Hungarian authorities to increase the number because of the inhumane conditions in which they are forced to camp here," he told the BBC.
But if 100 people were admitted each day, that would render the massive security operation on the far side, and the fence itself, irrelevant.
Hungary's October vote
The Hungarian government has called a referendum for 2 October to oppose refugee redistribution quotas proposed by the European Commission.
To be valid, the referendum will require at least 50% of Hungary's eight million voters to take part.
The government has launched a nationwide publicity campaign to mobilise the public to participate.
Some opposition parties have called for a boycott of the referendum, claiming that it would be a vote against Hungary's continued EU membership.
Migrants who have been pushed back to Serbia through the fence have accused police in Hungary of brutality.
Samir, from Afghanistan, says he was punched and kicked by police after he surrendered to them having gone four days in Hungary without water. He was then pepper-sprayed as he was being pushed back through the fence "to teach him a lesson".
"We have witnessed a lot of cases of intentional trauma that can be related to excessive use of force," said Momcilo Djurdjevic, a doctor from MSF (Doctors Without Borders), which has an active presence in both camps.
He lists testimonies from refugees and injuries that MSF has treated including "cuts, dog bites, and police, baton-shaped bruises on their bodies".
There has been no official Hungarian response to these allegations.
Official communiques note only that illegal migrants caught on Hungarian territory are "escorted" back to the border.
Faisal Sarwary from Kandahar has been in the Horgos camp for two weeks, with his father, mother, and four sisters.
Smugglers in Belgrade offered them an illegal trip to Austria, across Hungary, but "my father didn't accept. We just want to be patient and pass these borders legally".
A note on terminology: The BBC uses the term migrant to refer to all people on the move who have yet to complete the legal process of claiming asylum. This group includes people fleeing war-torn countries such as Syria, who are likely to be granted refugee status, as well as people who are seeking jobs and better lives, who governments are likely to rule are economic migrants.