https://static01.nyt.com/images/2015/09/09/multimedia/migrants-blog-march/migrants-blog-march-facebookJumbo.jpg

After being detained for days at a Danish school, a group of about 300 refugees and migrants escaped on Wednesday morning, and about half of those began a march down the highway toward Sweden.

Refugees, many carrying babies and young children in their arms, formed a human chain across the road as they walked for miles.

The march along highway E45 was reminiscent of one last week in Hungary when as many as a thousand migrants left the Keleti train station in Budapest and began to walk to the border with Austria.

"We have no problem with the Danes, but our families are in Sweden," said Jaafar Alaawi, 62, from Baghdad. "What am I supposed to do here?"

Mr. Alaawi, who had a limp and used a cane, was traveling with four sons and a grandson.

Refugees along the march said they had fled the school because they were angry with how they were being treated in Denmark.

Umm Mohammad, a Palestinian refugee from the Yarmouk camp in Syria, was traveling with her son and daughter.

"We flipped twice in a boat, and we suffered at the hands of gangs, for them to bring us here and fingerprint us?" said Ms. Mohammad, 45. "We'll only fingerprint in the country we want."

Arab bystanders, standing above a bridge on the main highway, tossed supplies to the refugees crossing below: water, bags of toast, and in one case a whole grilled chicken wrapped in aluminum foil.

"We are with you, go with God!" shouted one woman in Arabic.

A Syrian Christian from Damascus who was wearing a wooden necklace of beads and a cross around his neck pushed a stroller carrying his sleeping 5-year-old daughter. He lagged behind the rest of the group, and two teenage boys from Darfur, Sudan, slowed down to help him.

"We are going to Sweden," one of the boys, Ali Eissa, 16, said.

Told that Sweden was far away, he replied: "No problem, we can go."

The boys, whose ultimate destination is Norway, said they had been stunned by the hostile reception in Denmark. When they were in Germany, a police officer told them they were free to stay in the country or move on. They boarded a train from Cologne to Malmo, Sweden, paying 336 euros for their two tickets.

But the Danish police took them off the train and detained them at the school in Padborg, near the border with Germany.

Like many of the refugees stuck in the school, they were eager to continue their journey to Sweden.

But before they had the chance to walk to Malmo, the Danish police swooped in and separated the laggards from the larger procession ahead. They forced the Syrian father, his daughter and the two Sudanese boys onto a police bus with about 20 others who had been rounded up at the same time. As the police pushed the father onto the bus, he lost his loafers.

The Danish police, who earlier in the day had said they allowed the refugees to storm out of the school because they were not allowed to use violence, did not seem to hesitate to use force in pushing marchers to the ground and onto a bus.

A policewoman treated at least one journalist following the migrants the same way. Despite efforts to identify myself as a journalist, she pushed me to the ground and then forced me onto the bus.

A police officer pushed another young man to the ground so hard that the man's hands were cut on the pavement.

A little boy, looking scared, began to sob.

Asked to comment on the violence, a spokeswoman for the Jutland police later denied that anyone had been pushed.

“Our strategy is to talk to them to get a dialogue and to convince them that it is best to go back," said Lene Scharff, the police spokeswoman. "If we had used force they would not still be at the highway."

Ms. Scharff added that approximately 300 refugees and migrants left the school on Wednesday morning.

"They were not in prison," she said. "They were there so they could be registered. The door was not locked."

She said that perhaps half had gone to the highway and the rest had dispersed in small groups.

Buses carrying the migrants and this reporter from the march brought them back to the school in Padborg. It was littered with abandoned sleeping bags and backpacks.

Back at the school, a police officer put a number on my hand with blue marker: 1919.

An hour or so later, I walked out of the school without being stopped.

As of Wednesday evening, there were about 250 refugees still at the school, Ms. Scharff, the police spokeswoman, said. As I left the school, however, there seemed to be far fewer than that. Some refugees said later that over the past two days a steady stream of refugees had been taken to other detention centers before being sent back to Germany.

Ms. Scharff said that the migrants could choose to go to Germany or stay in Denmark. "We cannot send them to Sweden," she said. "That would be wrong. That's not the agreement that we have."

The migrant crisis has led to disruptions in train and bus service between Denmark and Germany, restrictions on ferry service and stalled traffic on the highway, according to Danish news reports.

Ms. Scharff said she did not know how much longer the migrants would be allowed to walk on the highway. "I can't tell you what our next move is," she said.

As of 8 p.m. on Wednesday, refugees who had been blocked from taking trains to the north filled the train station at Flensburg, on the German side of the border with Denmark. Some said they hoped to be able to travel north the next day.

Nabih Bulos contributed reporting.