The Government of the United Kingdom maintains intelligence agencies within several different government departments . The agencies are responsible for collecting and producing foreign and domestic intelligence, providing military intelligence, performing espionage and counter-espionage. Their intelligence assessments contribute to the conduct of the foreign relations of the United Kingdom , maintaining the national security of the United Kingdom , military planning and law enforcement in the United Kingdom .  The three main agencies are the Secret Intelligence Service (MI6), the Security Service (MI5), and the Government Communications Headquarters (GCHQ).
The history of the organisations goes back to the 19th century. The decryption of the Zimmermann Telegram in 1917 was described as the most significant intelligence triumph for Britain during World War I,  and one of the earliest occasions on which a piece of signals intelligence influenced world events.  During the Second World War and afterwards, many observers regarded Ultra as immensely valuable to the Allies of World War II . In the post-war period, intelligence cooperation between the United Kingdom and the United States became the cornerstone of Western intelligence gathering and the " Special Relationship " between the United Kingdom and the United States. 
|Domestic intelligence||Security Service (MI5) ||Counter terrorism and counter espionage intelligence gathering and analysis.||4,053 |
|Office for Security and Counter-Terrorism (OSCT)||Counter terrorism and protecting critical national infrastructure.||551 |
|National Domestic Extremism and Disorder Intelligence Unit (NDEDIU) ||Counter extremism and public disorder intelligence gathering and analysis.|
|National Crime Agency (NCA) ||Organised crime intelligence gathering and analysis.||4,516 |
|National Ballistics Intelligence Service (NBIS) ||Illegal firearms intelligence analysis.||40 |
|National Fraud Intelligence Bureau (NFIB) ||Economic crime intelligence gathering and analysis.||90 |
|Foreign intelligence||Secret Intelligence Service (SIS/MI6) ||Foreign intelligence gathering and analysis.||2,594 |
|Defence Intelligence (DI) ||Military intelligence analysis.||3,655 |
|Signals intelligence||Government Communications Headquarters (GCHQ) ||Signals intelligence gathering and analysis.||5,806 |
|Joint intelligence||Joint Intelligence Organisation (JIO) ||Joint intelligence analysis.||58 |
Organised intelligence collection and planning for the government of the United Kingdom and the British Empire was established during the 19th century. The War Office , responsible for the administration of the British Army , formed the Intelligence Branch in 1873, which became the Directorate of Military Intelligence . The Admiralty , responsible for the command of the Royal Navy , formed the Foreign Intelligence Committee in 1882,  which evolved into the Naval Intelligence Department (NID) in 1887.  The Committee of Imperial Defence , established in 1902, was responsible for research, and some co-ordination, on issues of military strategy .
The Secret Service Bureau was founded in 1909 as a joint initiative of the Admiralty and the War Office to control secret intelligence operations in the UK and overseas, particularly concentrating on the activities of the Imperial German government. The Bureau was split into naval and army sections which, over time, specialised in foreign espionage and internal counter-espionage activities respectively. This specialisation, formalised prior to 1914, was a result of the Admiralty intelligence requirements related to the maritime strength of the Imperial German Navy. In 1916, during World War I , the two sections underwent administrative changes so that the internal counter-espionage section became the Directorate of Military Intelligence Section 5 ( MI5 ) and the foreign section became the Directorate of Military Intelligence Section 6 ( MI6 ), names by which the Security Service and Secret Intelligence Service are frequently known in popular culture today.
The Naval Intelligence Division led the Royal Navy's highly successful cryptographic efforts, Room 40 (later known as NID25). The decryption of the Zimmermann Telegram was described as the most significant intelligence triumph for Britain during World War I,  and one of the earliest occasions on which a piece of signals intelligence influenced world events. 
The Imperial War Cabinet was the British Empire's wartime coordinating body. In 1919, the Cabinet's Secret Service Committee, recommended that a peace-time codebreaking agency should be created. Staff were merged from NID25 and MI1b into the new organisation, which was given the cover-name the " Government Code and Cypher School " (GC&CS).
The Joint Intelligence Committee was founded in 1936 as a sub-committee of the Committee of Imperial Defence. During World War II , it became the senior intelligence assessment body for the United Kingdom government.
Following the outbreak of the Second World War in 1939, the RAF Intelligence Branch was established, although personnel had been employed in intelligence duties in the RAF since its formation in 1918.
The Special Operations Executive (SOE) was a World War II organisation operational from 1940 until early 1946. SOE conducted espionage , sabotage and reconnaissance in occupied Europe and later in occupied Southeast Asia against the Axis powers and aided local resistance movements .
During the Second World War, the Government Code and Cypher School was based largely at Bletchley Park working on, most significantly, the German Enigma machine (codenamed Ultra ) and Lorenz ciphers , but also a large number of other systems. Winston Churchill was reported to have told King George VI , when presenting to him Stewart Menzies (head of the Secret Intelligence Service and the person who controlled distribution of Ultra decrypts to the government): "It is thanks to the secret weapon of General Menzies, put into use on all the fronts, that we won the war!" F. W. Winterbotham quoted the western Supreme Allied Commander, Dwight D. Eisenhower , at war's end describing Ultra as having been "decisive" to Allied victory. Sir Harry Hinsley , Bletchley Park veteran and official historian of British Intelligence in World War II, made a similar assessment about Ultra, saying that it shortened the war "by not less than two years and probably by four years"; and that, in the absence of Ultra, it is uncertain how the war would have ended.
GC&CS was renamed the " Government Communications Headquarters " (GCHQ) in 1946. Wartime signals intelligence cooperation between the United Kingdom and the United States continued in the post-war period.  The two countries signed the bilateral UKUSA Agreement in 1948. It was later broadened to include Canada, Australia and New Zealand, known as the Five Eyes , as well as cooperation with several "third-party" nations. This became the cornerstone of Western intelligence gathering and the " Special Relationship " between the UK and the USA.  Since World War II, the chief of the London station of the United States Central Intelligence Agency has attended the Joint Intelligence Committee's weekly meetings. One former US intelligence officer has described this as the "highlight of the job" for the London CIA chief.  Resident intelligence chiefs from Australia , Canada , and New Zealand may attend when certain issues are discussed.
In 1946 the Joint Intelligence Bureau (JIB) was established. The JIB was structured into a series of divisions: procurement (JIB 1), geographic (JIB 2 and JIB 3), defences, ports and beaches (JIB 4), airfields (JIB 5), key points (JIB 6), oil (JIB 7) and telecommunications (JIB 8).
The Joint Intelligence Committee moved to the Cabinet Office in 1957 with its assessments staff who prepared intelligence assessments for the committee to consider.
When the Ministry of Defence was formed in 1964, the Joint Intelligence Bureau, Naval Intelligence, Military Intelligence and Air Intelligence were combined to form the Defence Intelligence Staff (DIS). The DIS focussed initially on Cold War issues. 
The Security Service Act 1989 established the legal basis of the Security Service (MI5) for the first time under the government led by Margaret Thatcher . GCHQ and the Secret Intelligence Service (MI6) were placed on a statutory footing by the Intelligence Services Act 1994 under the government led by John Major .
In 2009, the Defence Intelligence Staff changed its name to Defence Intelligence (DI).  The Joint Intelligence Organisation was formalised to provide intelligence assessment and advice on development of the UK intelligence community’s analytical capability for the Joint Intelligence Committee and the National Security Council , which was established in 2010. 
The National Crime Agency , established in 2013, gathers and analyses intelligence on serious and organised crime.  It was preceded by the Serious Organised Crime Agency (2006–2013), National Criminal Intelligence Service (1992–2006), and the National Drugs Intelligence Unit (1970s–1992).
Four domestic intelligence units exist under the authority of the Home Office . The National Domestic Extremism and Disorder Intelligence Unit , which dates back to 2004 and has been hosted by the Metropolitan Police Service since 2011; the Office for Security and Counter-Terrorism , created in 2007, which is responsible for leading work on counter-terrorism working closely with the police and security services; the National Ballistics Intelligence Service , which was created in 2008; and the National Fraud Intelligence Bureau , which was established in 2010 by the City of London Police . 
Single Intelligence Account
The Single Intelligence Account (SIA) is the funding vehicle for the three main security and intelligence agencies: the Secret Intelligence Service (SIS/MI6),  Government Communications Headquarters (GCHQ)  and the Security Service (MI5).