Britain on Tuesday named Robert Hannigan as the next director of its electronic surveillance agency, GCHQ, which last year came under scrutiny for widespread spying alongside the United States’ National Security Agency. Mr. Hannigan, 49, who has been director general of defense and intelligence at the Foreign Office since 2010, will take over from Iain Lobban when he steps down in the fall, Foreign Secretary William Hague announced. Officials have denied that Mr. Lobban’s departure is linked to the controversy over the close relationship between GCHQ and the N.S.A., which was revealed in documents leaked by the former American intelligence contractor Edward J. Snowden. Under pressure to be more transparent, Mr. Lobban became the first head of the agency last November to give evidence in public before lawmakers.