Turkish President Tayyip Erdogan declared on Monday in an unexpected twist that the European Union should open the way for Ankara’s accession to the bloc before Turkey’s parliament approves Sweden’s candidacy to join the military alliance of the NATO.

Turkey’s EU bid has been frozen for years after accession negotiations began in 2005, during Erdogan’s first term as prime minister.

Ties between Ankara and members of the bloc soured several years ago, notably after a failed coup attempt in Turkey in 2016, but have since greatly improved. The bloc depends on help from NATO ally Ankara, especially on migration.

In an unexpected change of tack, Erdogan has linked Ankara’s approval of Sweden’s NATO candidacy with Turkey’s final membership of the EU.

“I appeal from here to these countries that have kept Turkey waiting at the gates of the European Union for more than 50 years,” Erdogan said, on the eve of his departure for the NATO summit in Vilnius.

“First, come and open the way for Turkey in the European Union and then we will open the way for Sweden, as we did with Finland,” he said, adding that he would repeat his call during the summit.

Sweden and Finland applied to join NATO last year, abandoning policies of military non-alignment that had endured through decades of the Cold War in response to Russia’s invasion of Ukraine.

While Finland’s NATO membership was given the green light in April, Turkey and Hungary have yet to give the go-ahead to Sweden’s candidacy. Stockholm has been working to join the bloc at the Vilnius summit. Erdogan said Sweden’s accession depends on the implementation of an agreement reached last summer during the alliance’s summit in Madrid, adding that no one should expect commitments from Ankara.

Ankara claims that Sweden has not done enough against those whom Turkey considers terrorists, mainly members of the banned Kurdistan Workers’ Party, which Turkey, the EU and the US consider to be a terrorist organization.

Erdogan has also claimed that the end of the war between Ukraine and Russia will facilitate Kyiv’s accession process to NATO.