ANKARA, Turkey —

Turkish President Recep Tayyip Erdogan warned Greece on Wednesday not to test his countrys patience or courage, further stoking tensions between the NATO allies over offshore energy exploration in the eastern Mediterranean.

Erdogans tough words came despite mediation efforts by Germany, whose foreign minister conducted shuttle diplomacy between Athens and Ankara a day earlier in a bid to deescalate the situation as Turkey and Greece engaged in competing military exercises at sea.

The neighboring countries are locked in an acrimonious dispute over maritime boundaries and offshore energy rights. They have sent warships to shadow each other in the eastern Mediterranean and held military exercises within a broad area between Crete and Cyprus where Turkey has a vessel conducting drilling research.

Turkey will take what is its right in the Mediterranean, in the Aegean and in the Black Sea, Erdogan said. Just as we have no eyes over anyones territory, sovereignty and interests, we will never compromise on what belongs to us. We are determined to do whatever is necessary in political, economic and military terms.

Erdogan added: We invite our interlocutors to get their act together and to avoid mistakes that will lead to their ruin.

German Foreign Minister Heiko Maas appealed to both Greece and Turkey on Tuesday to enter a dialogue and defuse the tensions, warning that any spark, however small, could lead to a disaster. His visits came ahead of a meeting of EU foreign ministers in Berlin later this week, at which Turkey will be discussed.

After talks with Maas, the foreign ministers of both Greece and Turkey signaled readiness for dialogue but blamed each other for the standoff.

The Turkish vessel Oruc Reis has for weeks been carrying out seismic research escorted by Turkish warships. Greece, which says the ship is operating over the countrys own continental shelf in an area where it has exclusive rights on potential undersea gas and oil deposits, sent warships to shadow the Turkish flotilla.

Turkey disputes Greeces claims, insisting that small Greek islands near the Turkish coast should not be taken into account when delineating maritime boundaries. Ankara accuses Athens of trying to grab an unfair share of the eastern Mediterraneans resources.

Turkey is also prospecting for hydrocarbons in waters where Cyprus claims exclusive economic rights. Ankara says it is protecting its rights and those of Turkish Cypriots on the ethnically-divided island.

Erdogan was speaking during celebrations marking the anniversary of the 1071 battle of Manzikert, during which Turkish Seljuks beat Byzantine forces, gaining entry into Anatolia.