More than 2,000 asylum seekers have walked en masse into Macedonia in defiance of European attempts to seal the continent’s southern borders to people fleeing war and poverty in the Middle East.

Dramatic photographs and videos showed crowds of men, women and children wading through the river on Monday afternoon to cross the Greek-Macedonian border, where more than 12,000 had been stuck for more than a week. Refugees stood in the water and formed human chains to pass babies and toddlers to safety on the other side, desperate to escape a squalid shanty town in northern Greece where medics have reported an outbreak of hepatitis A.

“It was a very difficult situation. There was a very big problem with the water, but everyone helped each other, and they crossed all together,” said Konstantinos Tsakalidis, a freelance photographer who walked with the marchers and who spoke to the Guardian by phone. “They were happy because they crossed the river, the border, and they believed that now they were free.”

But their act of defiance came to an end approximately one and a half miles inside Macedonia, when the country’s security officials forced the crowds to stop. As night fell, thousands of migrants were mostly sitting in a road, Tsakalidis said, while about 30 journalists were detained separately in the southern Macedonian town of Gevgelija.

Facebook Twitter Pinterest Men, women and children hold on to a rope as they attempt to cross into Macedonia. Photograph: Matt Cardy/Getty Images

Other witnesses, who preferred not to be named, said Greek police had done nothing to prevent the procession – though they had previously exhorted refugees through loudspeakers to leave the camp and move to organised shelters further south as there was no hope the border would reopen.

The scenes highlighted the flaws in the EU’s attempts to stop irregular migration to Europe, said the International Organisation for Migration (IOM). More than 500,000 people have passed this way in the last year, and from late last summer most of them were allowed to do so by the Balkan countries, which transported them from Macedonia to Germany using specially commissioned trains and buses, along a de facto humanitarian corridor.

Last Monday, this corridor was shut by agreement between the EU and its Balkan neighbours – although it was opposed by Berlin – trapping tens of thousands of migrants in Greece after they had landed from Turkey. The move was made in anticipation of a proposed deal between Turkey and Europe, which would see all future asylum seekers returned into Turkish hands.

Migration specialists have since warned that migrants would simply find other ways of reaching northern Europe, just as tens of thousands did prior to the creation of the Balkans humanitarian corridor last summer. On Monday, their predictions came to pass – with activists handing out leaflets that successfully encouraged migrants to take matters into their own hands.

Commenting on the events, IOM spokesman Leonard Doyle said: “Building walls and fences to stop migrants en masse is a recipe for trouble, as we see with people carrying young infants and walking across a cold river in full spate. Fences enrich smugglers and endanger migrants without homes to return to.”

Doyle added: “Urgent humanitarian solutions are required for migrants stuck on Greece’s northern borders.”

A representative of Médecins Sans Frontières, the medical aid group that has been present at the Greece-Macedonian border since last spring, said he had noticed an increase in irregular crossings and smuggling activity over the past week – and expected it to increase in the days and weeks ahead.

Jan van ’t Land, the deputy head of mission for MSF in Greece, said: “It’s easy to see. There are a few unofficial pick-up points and I pass them every day. From there, the smugglers will bring you over the border, and if you pay a couple of thousand they promise to take you to Germany. For single young men, this is an option if you have the money.”

He added: “For now it still seems to be [only at] the Macedonian border, but I would expect it to shift to Bulgaria. [Recently] I just walked into Bulgaria and then out without realising – so if I can do it then anyone can. But it doesn’t seem to be too popular yet.”

Attempts over the past two decades to control migration flows have usually simply seen migrants try their luck elsewhere. Increased policing of the Spanish borders with Morocco and west African countries led to a spike in Mediterranean crossings from Libya. Attempts to close Turkey’s land borders with Greece and Bulgaria were followed by the unprecedented flow of people to the Aegean islands in 2015.

Several thousand refugees are still stuck in a disease-ridden camp on the Greek side of the border, a spokesman for the UN refugee agency said. “We have been trying to convince people that the best way out is to apply for asylum and opt for the EU relocation scheme,” said Babar Baloch, the UNHCR spokesman at the camp.

“We estimate that of the 12,000 here, around 4,000 are children. The camp is just not a place that is fit for humans,” he told the Guardian. “People are tired, they are exhausted, their patience is running out. And when legal pathways are blocked, they are forced to give themselves up to traffickers and smugglers.”

The situation may yet worsen, with 4,000 people arriving in Greece over the weekend despite the new border restrictions, the UN said.

On Tuesday, Macedonia said it had detained 2,445 asylum-seekers overnight. At least 400 were returned to Greece, where they face being sent to army-run camps across the north of the country – but many more were still under arrest in Macedonia, aid workers said.

Van’t Land said: “We have the number of about 400 [returnees] – so maybe at least 1,000 are still on the Macedonian side, but nobody – not even UNHCR – knows what is happening to those people. They are detained by the Macedonian government.”

UNHCR’s Baloch said: “There’s no clarity. what is certain is that some people have come back, but it’s not clear whether they’ve all returned, or whether some are still still on the way.”

Save the Children placed direct blame for the situation on European governments. “After weeks waiting in increasingly appalling conditions on the border, families have been left feeling they have nothing left to lose,” Tanya Steele, the CEO of Save the Children, said from Greece. “They would rather brave a river crossing on a cold evening on the way to an uncertain future, than wait in limbo to potentially be sent back across the Aegean Sea.”

Steele added: “The scenes we saw last night were shocking and are a direct reaction to the wholly inadequate response of European leaders to this crisis, which treats people like bargaining chips and leaves them stranded with no safe plan for their future. The European migration plan that is currently on the table is pushing children to seek alternative, more dangerous routes to reach safety, making them an easy prey for smugglers and traffickers.”