Turkish President Recep Tayyip Erdogan has arrived in St Petersburg hoping to "reset" ties with Russia in talks with President Vladimir Putin.

It is Mr Erdogan's first foreign visit since an attempted coup last month.

Relations between the two countries were plunged into crisis last November when Turkey shot down a Russian military jet on the Syrian border.

The visit comes as Turkey's ties with the West have cooled over criticism of a crackdown on alleged coup-plotters.

Before leaving Turkey, Mr Erdogan referred to President Putin as his "friend" and said he wanted to open a new page in relations with Russia.

Erdogan unnerves West with Putin visit

"This visit strikes me as a new milestone in our bilateral relations, starting again from a clean slate," Mr Erdogan told Russia's Tass news agency.

After Turkey shot down the Su-24 jet in November, Russia imposed trade sanctions and suspended Russian package tours to Turkey.

What could each side gain from the visit?

The war of words over the downed Russian jet delivered a big blow to trade. Turkey's exports to Russia in the first half of this year fell to $737m (£567m) – a 60.5% slump compared to the same period last year, Turkey's Daily Sabah reported.

The dispute put two major joint energy projects on hold – the TurkStream gas pipeline across the Black Sea and the Akkuyu nuclear plant being built by Russia's Rosatom in Turkey.

Russia halts Turkey gas project talks

Before the dispute, Russia was a major export market for Turkish fruit and vegetables – so now Turkey is anxious to get the Russian import ban lifted.

There have been increasing signs that ties are improving. Late last month Russia resumed scheduled passenger flights to Turkey and said it was moving to resume charter flights. For years Turkey has been a magnet for Russian tourists, and its resorts suffered heavily from the trade embargo.

What led to the thaw?

In June, the Kremlin said Mr Erdogan had apologised for the downing of the jet and had sent a message expressing "sympathy and deep condolences" to the family of the dead pilot.

Then, after the 15 July coup attempt in Turkey, Mr Putin expressed support for Mr Erdogan. He did not criticise Mr Erdogan's crackdown on political opponents and purge of alleged "plotters" in state institutions.

The BBC's Sarah Rainsford says Russia is keen to capitalise on Turkey's cooling relations with the West following the failed coup.

Turkey's ties with its Nato allies – especially the US – have been strained by disagreements over the Syrian civil war. Turkey's priority is to weaken the Kurdish separatist forces, while the US is focusing on destroying so-called Islamic State (IS).

Mr Erdogan was angered by criticism from the EU and the US of the mass detentions of suspected plotters. He demanded that the US extradite Fethullah Gulen, the US-based Muslim cleric whom he accuses of organising the coup. But the US says Turkey must provide solid evidence before such a move can be considered.

Turkey's Justice Minister, Bekir Bozdag, says more than 26,000 people have been detained.

Where are there still Russia-Turkey tensions?

They back opposing sides in Syria. Turkey is furious at the scale of Russian air support for Syrian government forces, as Mr Erdogan reviles Syrian President Bashar al-Assad.

Russia has accused Turkey of backing Islamist anti-Assad groups, including some accused of "terrorism" in Russia.

Turkey is at war with the Kurdistan Workers' Party (PKK) and the PKK's Syrian allies. Mr Erdogan has accused Russia of arming the PKK.

For centuries Russia and Turkey have been rivals for influence in the Caucasus and Black Sea region.

Turkey was also angered by Russia's annexation of Crimea in 2014, accusing Moscow of violating the rights of Crimean Tatars. The Muslim Tatars have long had close ties to Turkey.