ISTANBUL (Reuters) - Two Greek soldiers facing espionage charges in Turkey are due to fly home early on Wednesday after a provincial court released them, in a ruling Athens said would help to improve strained ties between the two NATO allies.

Slideshow ( 10 images )

The soldiers crossed into Turkey in March, in what Greece said was an accident while they were following the trail of suspected illegal migrants.

But a court in the western province of Edirne ordered their detention the same month on suspicion of attempted military espionage.

The same court ruled for their release on Tuesday after they said in a defense statement they had crossed the border by mistake, state news agency Anadolu said.

Greek Prime Minister Alexis Tsipras welcomed the ruling. “The release of the two Greek officers is an act of justice which will contribute to friendship, good neighborly relations and stability in the region,” his office said in a statement.

The conditions of their release were not immediately clear, though Greece said it was sending an aircraft to pick them up.

The prime minister’s office said his plane would fly them back to Thessaloniki, where they would be received early on Wednesday by the defense minister.

Long-time regional rivals Turkey and Greece have been at odds over a host of issues from ethnically divided Cyprus to rights in the Aegean Sea.

Rhetoric has recently been ratcheted up on both sides, particularly after the collapse of peace talks in Cyprus in July 2017.

But following a meeting with Turkish President Tayyip Erdogan on the sidelines of a NATO summit in July, Tsipras said they had agreed to focus efforts on easing tensions in the Aegean.

Turkey has also called on Greece to return eight Turkish commandos who have sought asylum there after commandeering a helicopter to flee Turkey as a coup against Erdogan crumbled in July 2016. Turkey says they were involved, and has demanded they be returned to face trial.

In Brussels, European Commission President Jean-Claude Juncker said he was delighted by news of the Greek soldiers’ imminent release.

“As I said (before)... Turkey has nothing to fear from its European neighbors. We want to see a democratic, stable and prosperous Turkey,” he posted on his Twitter feed.