Thousands of refugees stranded on Greece's border with Macedonia were suddenly allowed to cross into the Balkan nation late Saturday, hours after Macedonian security forces fired stun grenades at them for the second day in an increasingly futile attempt to block growing crowds of people fleeing conflicts in the Middle East for the safety of Europe.

After two days of tense standoffs — during which groups amounting to hundreds of refugees sporadically dashed past the forces and managed to cross the border — the lines of Macedonian police and soldiers abruptly parted. Security forces lowered their weapons as long lines of refugees ran, jogged and walked across.

Western Europe has scrambled to cope with rising numbers of increasingly desperate people fleeing Middle East conflicts. Impoverished Macedonia had declared a state of emergency Thursday, and police had sealed the border and fired tear gas and stun grenades on Friday as well.

In a separate development Saturday, Italian authorities said they were sending out rescue boats in response to SOS calls from 18 boats carrying about 3,000 refugees off the coast of Libya.

Conditions on the Macedonia-Greece frontier had deteriorated Saturday after the refugees — many of them escaping wars in Syria, Iraq and elsewhere — spent a cold night under open skies, drenched by heavy rain and with little or no access to food or water. Aid agencies had only a skeleton staff at the border, and said there was no additional help on the way as rain began to fall again late Saturday.

The United Nations refugee agency UNHCR had earlier urged Macedonia to reopen its border and to provide more help to the vulnerable. Macedonia argued that it must ration entry after up to 2,000 people began streaming in every day in recent weeks, and amid chaos at the local Gevgelija railway station as crowds stormed trains.

About 600 people had been allowed through overnight into Saturday, jammed into a 5 a.m. local time train headed north toward Serbia, the last stop on a long road from the Middle East, Africa and Asia to Hungary and Europe’s borderless Schengen zone.

More arrived by foot on the Greek side as morning broke, many of them Syrian refugees brought by boat chartered by the Greek government to the mainland from suddenly crowded Greek islands such as Kos. About 50,000 hit Greek shores in July alone.

"It’s really cold here," said 30-year-old Faroq Awais, from Pakistan, waiting for a train in Gevgelija. "Last night it was raining and we couldn’t go anywhere inside. We were sleeping against the walls of a building, but it didn’t help."

Aid workers have criticized Macedonia for refusing to allow the refugees into the country.

Some authorities are calling these people "rioters," but "they are actually refugees," said Giorgos Kosmopoulos, Amnesty International’s chief for Greece. "Macedonia must be able to make this distinction."

He called the actions of Macedonian security forces "simply appalling," and said there were children and pregnant women in the crowd.

A bottleneck of people had formed at the border crossing by Saturday morning, and more refugees continued to arrive throughout the day. Large numbers of Syrian refugees had moved back from the crossing in an attempt to separate themselves from other nationalities. Some of the Syrians claimed that many of the others were not refugees, but economic migrants who came from other countries and identified themselves as Syrians.

However, the United Nations has determined that most people attempting to get into Europe over the summer have been seeking asylum.