INDJIJA, Serbia — Desperate and cold after spending the night out in the open, more than 100 migrants who set off on foot toward the Hungarian border to protest EU’s closed borders agreed Wednesday to end their march and return to the Serbian capital of Belgrade.

Some wrapped in blankets and carrying backpacks, the migrants boarded two buses in the town of Indjija, about 40 kilometers (24 miles) north of Belgrade, where they camped overnight at a local gas station, braving rain and snapping wind.

Most of the migrants were young men and boys from countries like Afghanistan or Pakistan who stand little chance of getting into Hungary or other EU nations. The protest march ended on the same day as an Afghan aid conference in Brussels sought to fight poverty in the country.

The so-called Balkan migrant route, used by nearly 1 million people fleeing wars and poverty last year, formally closed in March, forcing migrants to use alternative routes and pay hefty sums to smugglers to get them across.

Serbian refugee officials said the migrants involved in the protest would be taken to the country’s already overcapacity centers for asylum-seekers, where thousands have been staying for months waiting for a chance to cross into neighboring EU nations Hungary or Croatia.

More than 6,000 migrants and refugees remain stuck in Serbia after Hungary this summer introduced strict limits on the number of asylum-seekers allowed to cross into the country and reinforced a razor-wire border fence with heavy patrols.

Hungary has refused to accept any of the migrants that the EU is trying to relocate from Italy and Greece, and Hungarian voters on Sunday overwhelmingly rejected any future mandatory quotas for accepting asylum-seekers. The referendum was rendered invalid because of low turnout.

“I am requesting to Hungarian people to please open the border,” pleaded 16-year-old Hanwali Ahmadzai from Afghanistan. “It was raining and we were cold.”

Ahmadzai was among some 400 migrants that initially took off Tuesday from Belgrade toward the border 200 kilometers (120 miles) away to demand that the border be opened for people fleeing war and poverty. More than half from the group gave up along the way as the rain started and the evening fell.

Serbia’s Refugee Commissioner Vladimir Cucic, who came to Indjija to help persuade the migrants to end their march, said the group first was going to Belgrade before being transferred to the asylum centers.

“They think someone is waiting for them with open arms 200 kilometers (125 miles) away,” he said.

Serbia, too, has beefed up border patrols with Macedonia and Bulgaria to stop the migrants coming in from those countries. On Wednesday, Serbian police said they arrested a Serbian and a Bulgarian citizen suspected of smuggling 71 migrants through the country.

The migrants at the gas station in Indjija sat on the concrete pavement as they were waiting for the buses to pick them up. Two small boys used a wooden plank and an old tennis ball to play, while some ate the food distributed by aid officials as police stood by.

Muslim Khan, 18, from Afghanistan, said he came to Serbia two months ago through Bulgaria, while it was still summer and the weather was nice. Pulling a striped blanket tightly around his body to protect him from the wind, Khan said he now didn’t know what to do next.

“I have no jacket,” he said. “It was really cold and difficult and hard because we walked.”

Khan said he didn’t know how to return home even if he wanted to. He said that it is “difficult to go to Bulgaria,” claiming that Bulgarian police had roughed up his group and taken away their belongings.

“We stay here (in Serbia) and wait, and when border opens we will try our best,” he said.