Why is Theresa May talking to President Erdogan, the authoritarian leader of Turkey? Some on the liberal left think she shouldn’t be cosying up to a leader who has cracked down on human rights and freedom of speech. Some on the right wonder what she is doing making nice with the great scare story they used during the EU referendum campaign – wasn’t the point of Brexit to put up barriers against countries like this?

Neither objection makes much sense. You don’t have to sign up for all the diplomatic rhetoric of “indispensable partner” and “close ally” to know that Turkey is important to Britain whether we are in the EU or not.

The liberal left’s case against the Prime Minister’s visit didn’t last long when Sarah Olney, the new Liberal Democrat MP, went on LBC radio on Saturday. She opposed the visit because it “betrays our liberal values”, but when Iain Dale reminded her that Nick Clegg as Deputy Prime Minister had led a trade mission to Turkey five years ago, she was reduced to saying that Britain was in a stronger position then to demand respect for human rights.

Turkey releases video of air strikes on more than 100 Isis targets in Syria after Istanbul nightclub attack

The isolationist case against the visit is equally weak. Even if you voted Leave because you thought Turkey was about to join the EU – which it isn’t – you might see that the country is on the front line of the Syrian refugee crisis. To put it crudely, if your priority is to reduce immigration, then it would make sense to maintain good relations with a country that has taken 2.7 million Syrian refugees.

Both sides are confused, too, about trade. Liberal Remainers think they have scored a debating point when they say that Turkey has a customs union with the EU, and so it cannot sign a separate trade deal with Britain. But, as Clegg’s trip in 2012 suggested, it was worth Britain talking to Turkey about trade even when Britain was a member of the EU customs union.

These are deep technical waters. It is often said that the British civil and diplomatic services lack the experienced trade negotiators needed to make a success of Brexit after 44 years in which EU officials negotiated such things on our behalf. A similar charge can also be made against British journalists: few of us understand the complexities of trade agreements. What I have picked up from experts is that Turkey has a “customs union” with the EU, but it is not a member of “the” EU customs union. The Turkish deal applies to many goods but not to agriculture or to services, and it allows the Turkish government to negotiate its own trade deals as long as its external tariffs align with the EU’s.

So, when Britain leaves the EU, it will be able to do limited trade deals with Turkey, in addition to the drumming up of investment and the informal trade links Clegg thought it worth trying to promote.

Of course, embarrassing as Clegg’s visit was to Lib Dem sanctimony about May’s trip, it is not a full answer to how Britain should balance disapproval of the Erdogan government’s policy against the value of good relations with an important regional power. But my view is that, generally, engagement is better than isolation and sanctions. The threshold for sanctions has to be high – such as Russia’s responsibility for carnage in Syria.

In pictures: Turkey coup attempt Show all 17 1 /17 In pictures: Turkey coup attempt In pictures: Turkey coup attempt Turkish President Erdogan attends the funeral service for victims of the thwarted coup in Istanbul at Fatih mosque on July 17, 2016 in Istanbul, Turkey Burak Kara/Getty Images In pictures: Turkey coup attempt Soldiers involved in the coup attempt surrender on Bosphorus bridge with their hands raised in Istanbul on 16 July, 2016 Gokhan Tan/Getty In pictures: Turkey coup attempt A civilian beats a soldier after troops involved in the coup surrendered on the Bosphorus Bridge in Istanbul, Turkey, 16 July, 2016 REUTERS/Murad Sezer In pictures: Turkey coup attempt Surrendered Turkish soldiers who were involved in the coup are beaten by a civilian Reuters In pictures: Turkey coup attempt Soliders involved in the coup attempt surrender on Bosphorus bridge Getty In pictures: Turkey coup attempt Supporters of Turkish President Recep Tayyip Erdogan wave flags as they capture a Turkish Army vehicle Getty In pictures: Turkey coup attempt People pose near a tank after troops involved in the coup surrendered on the Bosphorus Bridge in Istanbul, Turkey, 16 July, 2016 Reuters In pictures: Turkey coup attempt Turkish soldiers block Istanbul's Bosphorus Brigde Getty In pictures: Turkey coup attempt A Turkish military stands guard near the Taksim Square in Istanbul Reuters In pictures: Turkey coup attempt Pierre Crom/Twitter In pictures: Turkey coup attempt Turkish soldiers secure the area as supporters of Recep Tayyip Erdogan protest in Istanbul's Taksim square AP In pictures: Turkey coup attempt People demonstrate in front of the Republic Monument at the Taksim Square in Istanbul Murad Sezer/Reuters In pictures: Turkey coup attempt Turkish soldiers detain police officers during a security shutdown of the Bosphorus Bridge Reuters In pictures: Turkey coup attempt Turkish Army armoured personnel carriers in the main streets of Istanbul Getty In pictures: Turkey coup attempt Chaos reigned in Istanbul as tanks drove through the streets EPA/TOLGA BOZOGLU In pictures: Turkey coup attempt Turkish President Tayyip Erdogan speaks to media in the resort town of Marmaris Reuters In pictures: Turkey coup attempt Supporters of President Erdogan celebrate in Ankara following the suppression of the attempted coup Reuters

There is much to be alarmed about in recent Turkish history. The coup six months ago remains mysterious. Erdogan blamed it on the cultish followers of Fethullah Gulen, the Islamic preacher exiled in, of all places, Donald Trump’s America. This looks awfully like the Big Brother tactic of waging permanent war against an external enemy to justify authoritarian rule. But it is also worrying because the idea that the Gulenist threat is being orchestrated by “the West” strengthens the extremist strain in a Muslim country hitherto largely untouched by anti-western ideology.

So it makes sense to engage with the regime, a player not just in Syria but in Iraq, and a member of Nato.

The more interesting question is why Theresa May is talking to Erdogan but not to Putin. Her scepticism about China and Russia has been a theme of her first six months as Prime Minister. There was a notable section of her speech to Republican senators and members of Congress on Thursday. She said: “Countries with little tradition of democracy, liberty and human rights – notably China and Russia – have grown more assertive in world affairs.” And she pointedly contrasted China with “democratic allies like India”, although she has visited both countries.