Senior Foreign Office official Robert Hannigan has been named as the next head of the UK's eavesdropping agency GCHQ.
He will succeed Sir Iain Lobban at GCHQ, which has come under intense scrutiny following the revelations about its activities by US whistleblower Edward Snowden.
Unlike Sir Iain, who rose through the ranks at GCHQ, Mr Hannigan is an outsider, currently serving as director general of defence and intelligence at the Foreign Office.
He will take over the role at the Cheltenham-based agency in the autumn.
Foreign Secretary William Hague said Mr Hannigan had "impressive personal qualities" and a "wealth of relevant experience in the fields of national security, counter-terrorism and international relations".
Reports suggested that Home Office counter-terrorism chief Charles Farr was also shortlisted for the GCHQ role, along with an unnamed senior MI6 spy.
Mr Hannigan, who was born in Gloucestershire, not far from GCHQ's base, has advised the Prime Minister on counter-terrorism, intelligence and security policy.
In his Civil Service career he was principal adviser to then prime minister Tony Blair on the Northern Ireland peace process and was also responsible for the UK's first cyber security strategy and oversaw the first national security strategy.
Mr Hague said: "I am delighted that Robert Hannigan has been appointed as the next director of GCHQ. GCHQ's world-class work is vital to the safety and security of the United Kingdom.
"As well as his impressive personal qualities, Robert brings to the job a wealth of relevant experience in the fields of national security, counter-terrorism and international relations.
"I'd also like to thank Sir Iain Lobban for his consistently strong and professional leadership as director of GCHQ since 2008."
Mr Hannigan said: "It is a privilege to be asked to lead GCHQ, an organisation which is so central to keeping the people of this country safe.
"I have great respect for the integrity and professionalism of the staff of GCHQ and for what they have achieved under the outstanding leadership of Iain Lobban. I am excited about meeting the challenges of the coming years with them."
The recruitment process was chaired by National Security Adviser Sir Kim Darroch, who said: "I am delighted Robert Hannigan has been appointed director, GCHQ.
"He will bring energy, flair, deep knowledge and extensive experience to the role, and I look forward to working closely with him. I would also like to take the opportunity to thank Sir Iain Lobban.
"Iain has been a close friend and colleague over my time as National Security Adviser and has done an absolutely outstanding job at an exceptionally testing time for the organisation."