REYHANLI, TURKEY -- Turkey's President Recep Tayyip Erdogan said his country's borders with Europe were open Saturday, making good on a longstanding threat to let refugees into the continent as thousands of migrants gathered at the frontier with Greece.

Erdogan's announcement that Turkey is allowing refugees and migrants to exit the country marked a dramatic departure from current policy and an apparent attempt to pressure Europe.

It came amid a military escalation in northwestern Syria's Idlib province that has forced hundreds of thousands of Syrian civilians to flee fighting between advancing Syrian government forces backed by Russia and rebel fighters supported by Turkey.

The mass displacement in Idlib has raised the possibility that Turkey might come under growing international pressure to open its now sealed border with Syria and offer refuge to desperate Syrian civilians.

"We can't handle a new wave of migration," Erdogan said Saturday, in an apparent reference to the growing humanitarian crisis in Idlib. Nearly 950,000 displaced civilians have been pushed toward the Syrian-Turkish border amid cold winter weather.

Erdogan said Turkey would not stand in the way of refugees and migrants already in the country who hope to head to Europe.

"We will not close the gates to refugees," he said. "The European Union has to keep its promises. We are not obliged to look after and feed so many refugees."

Under a 6 billion euro deal in 2016, Turkey agreed to stem the tide of refugees to Europe in return for financial aid after more than a million people entered Europe in 2015. It has since accused the EU of failing to honour the agreement. Erdogan has frequently threatened to "open the gates" and allow refugees and migrants to head to Europe unless more international support was provided.

The German foreign ministry said it was in contact with other governments regarding the matter and assumed and expected that the EU-Turkey agreement will be adhered to.

Since seizing territory from Kurdish forces in a different part of Syria in October, Erdogan has also suggested resettling at least a million Syrian refugees from Turkey in that northeastern region. However, his efforts to secure funding for such a scheme have been rejected by European governments. Aid groups have said it is still too dangerous to return refugees to Syria.

Turkey currently hosts more than 3.5 million Syrian refugees, and many others fleeing war and poverty in Asia, Africa and the Middle East use it as a staging post and transit point to reach Europe, usually through neighbouring Greece.

Migrants played a cat-and-mouse game with Greek border patrols Friday night through Saturday, with Greek authorities firing tear gas to repulse the crowd's attempts to push through the border. Greek officials said migrants lobbed at least 20 canisters of tear gas toward the border from the Turkish side.

Greek officials arrested 66 migrants Friday, 17 of whom were sentenced to 3.5 years in jail for entering the country illegally. All Afghans, they were are the first migrants sentenced for illegal entry since 2014. On Saturday, Greece arrested another 70 migrants who tried to cross the border from Turkey.

Some migrants cut holes in the fence, with a few managing to get through. They took shelter overnight in abandoned buildings or small chapels in the Greek countryside before starting to walk toward northern cities.

Others were crossing from the Turkish coast to nearby Greek islands.

Greece announced it was sending police and army reinforcements to its land border and reinforcing controls along the sea border, where 52 coast guard and navy vessels were patrolling.

Citizen Protection Minister Michalis Chrisochoidis visited the border and described the situation as "difficult and unpleasant."

"Thousands of unfortunate people are cramming on our border; they have not come here of their own accord," he said. "They are being pushed, repulsed and used by our neighbouring country Turkey." The minister insisted no one without legal travel documents would be allowed to cross.

Erdogan's speech Saturday in Istanbul was the first clear announcement that migrants would be allowed to try to cross the border, after a foreign ministry spokesman floated the idea Thursday, prompting the first wave of migrants to head to the border.

It comes as tensions ratcheted up between Turkey and Syria. More than 55 Turkish troops have been killed since Turkey began sending reinforcements into rebel-held areas of Syria earlier this month. Thousands of Turkish soldiers are deployed inside Syria's Idlib province, which is dominated by al-Qaida-linked militants.

Turkey's Defence Ministry said late Friday that one of its soldiers was killed and two were injured by Syrian government shelling. It was the latest fatality after a deadly airstrike killed 33 earlier this week.

Kamal Alam, a military analyst specializing in Turkey and Syria, said Turkey's frustration at being "left alone" by its NATO allies in Syria had been exacerbated by the 33 deaths.

"Despite being a NATO member, on the ground nobody is supporting Turkey's stance. Turkey's saying to Europe `If you're going to leave us alone and not help us then we're going to bring the war to your doorstep."'

------  Kantouris reported from Kastanies, Greece. Elena Becatoros in Athens contributed to this report.