Turkey on Tuesday released from prison two Greek soldiers held for almost six months for allegedly illegally crossing the border between the two countries, in a move Greece's prime minister welcomed as "an act of justice."

Alexis Tsipras said in a statement that the men's release will help boost friendship between the two historic regional rivals. Tsipras also thanked the two soldiers and their families for their "fortitude and patience" while in prison in the western Turkish town of Edirne.

The incident had tested Greek-Turkish relations, with Greek officials arguing that the men accidentally crossed a poorly marked section of the heavily militarized border while on patrol in bad weather on March 1. Turkish authorities rejected repeated Greek requests for their release.

Greece's defense minister had claimed that they were being held "hostage" by Turkey, which is trying to secure the extradition of eight Turkish servicemen who fled to Greece after the 2016 failed military coup in Turkey. Ankara accuses its servicemen of involvement in the coup, but Greek courts have refused to extradite them, arguing they would not get a fair trial in Turkey and their lives would be in danger there.

The two Greek soldiers were released Tuesday pending the outcome of their trial by a Turkish court. A Greek government official said no travel ban was imposed and they were expected to return to Greece Wednesday. The official spoke to the Associated Press on customary condition of anonymity.

Turkey's state Anadolu Agency said that in a court hearing to review a request for their release the two said in their defense that they had crossed the border by mistake.

The father of the one man, 2nd Lieutenant Angelos Mitretodis, told the AP that he was awaiting details on when his son is due back.

"My wife phoned and told me the news, and at once I called the Greek consul (in Edirne) and confirmed that the lads have been set free," Nikos Mitretodis said. "They didn't do anything wrong, and they spent a long time in prison. But they were strong during all that time, and remain strong, they have to be."

"I want to thank everyone for their solidarity — the media, our political leadership, the Church and anonymous people who stood by us," he added.

___

Kantouris reported from Thessaloniki, Greece. Suzan Fraser contributed from Ankara, Turkey.