Greek Prime Minister Alexis Tsipras paid a symbolic visit to Istanbul's former cathedral Hagia Sophia on Wednesday on a trip aimed at improving ties with Turkey, long strained by disputes over territory, energy exploration and Cyprus.

President Recep Tayyip Erdoğan's spokesman Ibrahim Kalın accompanied Tsipras on his tour of Hagia Sophia, which was the foremost cathedral in Christendom for 900 years and one of Islam's greatest mosques for another 500 years. It has been a museum since 1935.

Tsipras also paid a historic visit to a former Greek seminary on Istanbul's Princes' Islands. He visited the site of the Halki Seminary on Heybeliada Island -- the first visit by a Greek leader in many decades.

At the seminary site, Tsipras took part in a religious ceremony headed by Fener Greek Orthodox Patriarch Bartholomew I.

Established in 1844, the seminary was closed in 1971 under a law that placed religious and military training under state control.

On Tuesday, Erdoğan suggested the seminary could be reopened if Athens improved conditions for the Muslim community in Western Thrace, an area of Greece with a large Turkish Muslim population.

Tsipras met Erdoğan in Ankara on Tuesday, where the Turkish president said he expected more cooperation from Athens in the repatriation of eight soldiers who fled to Greece following an attempted coup in 2016.

Tsipras told their joint news conference that Greece does not welcome putschists, but that the case of the eight soldiers was a matter for the judiciary.

He said both countries had agreed to de-escalate tensions in the Aegean Sea and proceed with confidence building measures. Differences with Turkey "can and must be solved with dialogue," he added.