Britain’s representative to Brussels has been nominated to be the EU’s new counter-terrorism security commissioner despite the UK voting to leave the European Union.

Sir Julian King has been given the key role by Jean-Claude Juncker, even though the European Commission President previously warned that British “deserters” from the EU would have to “face the consequences” of “being regarded as a third country, which won't be handled with kid gloves”.

The surprise move means that as the UK prepares to leave, a Briton will be the new Commissioner for the Security Union, tasked with helping to fight terrorism and cybercrime while assisting in the creation of a new Security Union of EU member states.

Mr Juncker has also told Sir Julian, who was sent to Brussels after the former commissioner Lord Hill of Oareford resigned following the Brexit vote, that he will have to help the Commissioner for Migration “develop solutions to forthcoming security challenges”.

In a mission letter sent on Tuesday outlining Sir Julian’s new role, Mr Juncker struck a markedly different tone to the one he adopted ahead of the EU referendum in May, when he told Le Monde: “Deserters will not be welcomed with open arms. The United Kingdom will have to accept being regarded as a third country, which won't be handled with kid gloves. If the British should say no, then life in the EU will not go on as before.”

Instead Mr Juncker’s letter to Sir Julian seems to imply an expectation of Britain and the EU sharing “a united and clear purpose” for years to come.

The Commission president told Sir Julian: “You are becoming a member of the European Commission at a particularly challenging time for the European Union. We will have a lot to do in the years to come and we will have to show a united and clear sense of purpose at all times.”

“The Union only succeeds,” Mr Juncker added, with no apparent sense of irony, “When everyone is pulling in the same direction.”

Telling Sir Julian he would play a key role in ensuring “an effective EU response to security threats over the period 2015-2020,” even though Britain may have left the EU by 2020, Mr Juncker wrote: “Security is one of the pressing challenges I have highlighted … In particular, three priorities were identified as needing to be addressed: tackling terrorism and preventing radicalisation, disrupting organised crime, and fighting cybercrime.

“Repeated subsequent terrorist attacks have underlined the importance and urgency of making swift progress towards an operational and effective Security Union.”

The appointment of a Briton to help implement Mr Juncker’s goal of creating a new EU security union is a particularly unexpected twist, given the fierce opposition the concept aroused among Eurosceptics in Britain.

When Mr Juncker first called for the Security Union in April, insisting “fragmentation is what makes us vulnerable,” he was bitterly attacked by supporters of Brexit.

Ukip’s defence spokesman, the MEP Mike Hookem claimed: “Juncker must be literally mad if he thinks British people will sign up to a security union with the EU. Does he really believe that inexperienced bureaucrats at the European Commission are better placed to deal with British security than British security services?”

Sir Julian, a career diplomat and the outgoing UK ambassador to France, will report to a series of vice-presidents who form Mr Juncker's top team. In a recognition of the realities of Brexit, it is expected that unlike other commissioners he will not attend ministerial meetings.

Sir Julian’s appointment may signal a desire within the EU to retain strong links with the British security services, which are regarded as having a relatively impressive record in countering terrorism.

The security specialist Will Geddes told The Independent the UK’s security services were regarded as among the best in the world, and were often asked to advise intelligence agencies in other countries.

Mr Geddes said: “The UK and the US are probably the go-to countries in terms of depth and length of experience.

“We have world beating relationships in terms of how MI5 and MI6 co-ordinate. We are much more advanced in that respect than they are in Germany and particularly in France. There are about seven French intelligence agencies and a lot less of a consolidated effort, which is half the reason they have been having as many problems [with terrorist attacks] as they have.”

Mr Geddes, the founder and managing director of International Corporate Protection, speculated that Mr Juncker might be hoping that as a career diplomat Sir Julian might prove a useful, neutral and uncontroversial conduit into British Government circles.

He said: “The boiler room practices [and co-operation] of the national security agencies will carry on regardless of Brexit, but this could provide a join-up on higher, more political and judicial levels for counter-terrorism issues.

“However upset the EU may be about Brexit, they appreciate they have got to be able to have a civil conversation about these issues.”

Theresa May says she has an 'open mind' over Brexit negotiations

Before Sir Julian can start work, however, his appointment to the newly created role of Commissioner for the Security Union must be approved by MEPs.

A European Commission press release announcing Mr Juncker’s intention to give Sir Julian the security brief states: “President Juncker is sending today a letter to Martin Schulz, president of the European Parliament informing the latter of his intention to allocate to Sir Julian King the responsibility for the Security Union portfolio.

“An exchange of views between Sir Julian and the relevant Committee of the European Parliament is expected to take place in early autumn.”

There is no guarantee, however, that this “exchange of views” will be a rubber stamping exercise. In October 2014, Sir Julian’s predecessor Lord Hill, nominated by Mr Juncker to be Commissioner for Financial Stability, reportedly failed to impress MEPs and was summoned before them for a second hearing. The eventual confirmation of his appointment, it was claimed, required some “diplomatic smoothing of the way” by Mr Juncker.

After Mr Juncker telephoned Theresa May on Monday evening to tell her he was nominating Sir Julian for the security role, a Downing Street spokesman said: "We welcome this decision. The UK will continue to fulfil our rights and obligations as a member state until we leave the EU and the Prime Minister has been clear that we will be an active player.

"Security is a vital issue for all member states and co-operation across the EU can help to better protect us all from the range of threats we face. We now look forward to Sir Julian being confirmed in the role."