SKOPJE, Macedonia — Hours after several hundred migrants bypassed a line of baton-wielding police officers on Saturday to enter Macedonia from Greece, nearly all those remaining on the Greek side of the border were allowed in, according to video footage and human rights activists at the scene. By Saturday evening, only around 200 people were left behind a fenced area on the line that separates the two countries.

Some of the people who entered continued their trip north, toward the Serbian border, via taxis and private buses. But most headed toward the train station about three miles away in the border town of Gevgelija, joining more than 2,000 people there waiting for a train to Serbia and Hungary, and then on toward wealthier European countries.

Earlier in the day, the Macedonian police used stun grenades in an effort to restore control and to return those who had managed to slip across the border in an area where the police presence was thinner and where there was no barbed wire. Officers gave chase as migrants ran through fields near Gevgelija, but because of their sheer numbers, many escaped. Some officers kicked migrants and beat them with batons, but humanitarian workers said there were no serious injuries.

The migrants, most of them fleeing violence in Syria, Afghanistan and Iraq, had grown impatient after spending most of Friday night in open fields under heavy rainfall, according to activists. About 4,000 migrants crossed into Macedonia on Saturday, including those who slipped beyond the police cordon and those allowed in later.