By Fatos Bytyci

GEVGELIJA, Macedonia (Reuters) - Thousands of migrants stormed across Macedonia's border on Saturday, overwhelming security forces who threw stun grenades and lashed out with batons before apparently abandoning a bid to stem their flow through the Balkans to western Europe.

Some had spent days in the open with little or no food or water after Macedonia on Thursday declared a state of emergency and sealed its borders to migrants, many of them refugees from war in Syria and other conflicts in the Middle East.

But by nightfall on Saturday, thousands had crossed the frontier, milling around the border town of Gevgelija where busses had converged from all over the country and trains left in quick succession to take them north to the next leg of their journey through Serbia.

There was no official word from the government, but the level of organization suggested authorities had opted to move the migrants on as quickly as possibly, having tried and failed to keep them out with razor wire, teargas and stun grenades.

“The government is organizing additional trains. I don’t know who is organizing the busses,” said Alexandra Krause, a senior protection officer with the United Nations refugee agency, UNHCR.

No-man’s land, where men, women and children had slept in squalor under open skies appeared largely empty, though more people are certain make their way from Greece.

"In this Europe, animals are sleeping in beds and we sleep in the rain," said 23-year-old Syrian woman Fatima Hamido on entering Macedonia. "I was freezing for four days in the rain, with nothing to eat."

Thirty-two-year-old Saeed from Syria said of the blocked border: "We know this was not Macedonia and the Macedonian police. This was the European Union. Please tell Brussels we are coming, no matter what."

Migrants had been pouring across the border into Macedonia at a rate of some 2,000 per day, en route to Serbia then Hungary and Europe's borderless Schengen zone. Some 50,000 arrived on Greek shores in July alone by boat from Turkey.

Story continues

POOR RELATIONS WITH GREECE

The surge in numbers had overwhelmed Gevgelija, testing the patience of a conservative government that faces an election in April and has for years been thwarted in its efforts to join the European Union and NATO by a dispute with Greece over Macedonia's name.

The government criticized Greece, as an EU member, for letting the migrants through and in some cases aiding their passage by chartering ships to take them from inundated Greek islands to the mainland.

On Friday, riot police fired teargas and stun grenades to drive back angry crowds, in the latest flare-up in a migration crisis that has brought ripples from the conflicts of the Middle East to Europe's shores.

Some 600 were allowed through overnight, squeezing onto a dawn train north to the Serbian border. But more kept arriving on the Greek side, converging on a filthy, chaotic strip of frontier with little sign of an organized aid effort.

Some Greeks sold sandwiches and drinks to those prepared to pay. A man with a generator charged 1.5 euros to charge mobile phones.

Tired, angry and wet, one part of the crowd pushed through police lines, while others ran through open fields several kilometers from the bulk of police. Some small children were separated from their parents; people collapsed or staggered across with bloodied faces.

For many Macedonians, the crisis has echoes of 1999, when hundreds of thousands of ethnic Albanians took shelter in refugee camps on Macedonia's northern border during a war in neighboring Kosovo, then a province of Serbia.

(Additional reporting by Yannis Behrakis and Fedja Grulovic in IDOMENI, Greece; Writing by Matt Robinson; Editing by Robin Pomeroy)