In the nineteenth century the gathering and interpretation of intelligence from overseas by the British Government was undertaken by the Admiralty, the War Office and the Foreign Office. The Boer War focused the need for a further professionalisation of intelligence gathering, and in 1904 the Committee of Imperial Defence was formally established as an advisory body to the Cabinet and other relevant departments.

In 1909 a sub-committee of the Committee, established to plan counter measures against a possible German invasion, proposed the creation of a Secret Service Bureau, to deal with information from abroad, liaise with agents, and be responsible for counter-espionage in the United Kingdom and in the colonies. To protect the extreme secrecy under which the Bureau was intended to operate the sole contemporary copy of the sub-committee report was placed in the custody of the Director of Military Operations at the War Office; eventually, it was transferred to PRO as CAB 16/232.

The Bureau was established jointly by Captain Vernon GW Kell of the South Staffordshire Regiment, appointed under the Director of Military Operations at the War Office, and Captain Mansfield Cumming of the Royal Navy. Cumming, known simply as 'C', was responsible for gathering intelligence overseas, while Kell, known as 'K', was responsible for counter-espionage within Britain. It was funded from the secret service vote by the War Office, with formal accounts to be submitted to the Foreign Office.

At the outbreak of the First World War the Bureau was mobilised as a branch of the War Office and was put under MO5 Colonel, (who acted as its paymaster, military chief and director), as sub-section, MO5(g). Its duties were defined as: military policy in connection with civil population, including aliens and administration of defence of the realm regulations in so far as they concern the MO Directorate. Kell then had the help of three regular officers, who were transferred to the Reserve of Officers on undertaking this work, and a very small clerical staff.

Before the war a register had been compiled of all aliens in the United Kingdom, outside the east end of London, and lists had been prepared and handed to chief constables concerned of those persons who were known or were suspected of being German agents. When war was declared these persons were arrested.

On 1 October, 1914, MO5(g) was divided into three sub-divisions: MO5(g)a Investigation of espionage and cases of suspected persons; MO5(g)b co-ordination of general policy of government departments in dealing with aliens. Questions arising out of the Defence of the Realm Regulations and the Aliens Restriction Act, and MO5(g)c records, personnel, administration and port control.

By 1915 the Bureau dealt with military policy connected with the control of civilian passenger traffic to and from the United Kingdom, port intelligence and military permits. A system of military control of passenger traffic at home ports, which had steadily been growing in importance, was put on a new footing and a new subdivision was created: MOF(e). As a result, MO5(g)a became MO5(g), MO5 (g)b became MO5(f) and MO5(g)c became MO5(h). The whole of this, as well as the subsequently formed military permit offices in London, Paris, Rome, New York and Brussels being directly controlled by sub-sections of the bureau.

In January 1916 it became part of a new Directorate of Military Intelligence and the sub-sections MO5 (a) to (d) became MI6 whereas the sub-sections MO5(e) to (h) were titled MI5. It became responsible for coordinating government policy regarding aliens, vetting, and security measures at munitions factories, and was also responsible for overseeing counter-espionage measures throughout the British Empire. Following the Russian Revolution it began to counter perceived Communist subversion in the armed forces and sabotage to military installations. In 1918 it had 800 staff.

The Security Service was officially formed on 15 October 1931 when MI5 assumed responsibility for assessing all anticipated threats to the UK's national security apart from those posed by Irish terrorists and anarchists. Whilst the Security Service is the organisation's official title, the name MI5 continued in both official and popular use. In early 1939 the Service contained only 30 officers and its surveillance strength was only 6. In early 1941 Sir David Petrie was appointed the first Director General of the Security Service, and was given resources to rebuild it. During the war the Service had a high success rate in identifying and capturing German agents, some of whom were persuaded to become double agents.

In 1952 the Prime Minister deputed his personal responsibility for the Security Service to the Home Secretary Sir David Maxwell Fyfe, who issued a Directive describing the Service's tasks and setting out the role of the Director General. This Directive provided the basis for the Service's work until the Security Service Act in 1989. The Service's complement then stood at about 850, including about 40 Security Liaison Officers overseas who provided advice and assistance to governments in the Commonwealth and colonies. In the 1960s the identification of the spies Houghton, Blake, Vassall and others showed the need for greater concentration on counter-espionage. Lord Denning's report into the Profumo affair in 1963 revealed publicly for the first time details of the Service's role and responsibilities; the report (Cmnd. 2512) quotes the Maxwell Fyfe Directive (sometimes referred to as the Security Service's charter) in full.

By the late 1970s, counter-espionage work was superseded by activities to counteract international terrorism and Irish Republican terrorism. Until 1992 the Service was responsible for dealing with the latter only if it was outside the United Kingdom, but in that year it was given responsibility for leading intelligence operations against Irish republican terrorism on the British mainland.

Incidents such as the siege of the Iranian Embassy in 1980, and that of the Libyan People's Bureau in 1984, saw the Service establish a network for co-operation among Western security and intelligence services. In 1983 a member of the Service was convicted of espionage. The subsequent Security Commission inquiry was critical of the Service's personnel management, and Sir Antony Duff was appointed to institute major reforms.

The Service was placed on a statutory basis by the Security Service Act 1989. This confirmed that the Home Secretary was formally accountable for the Security Service, the Prime Minister having ultimate responsibility for the defence and security of the realm.

The Service is headed by a Director General, who is appointed by the Home Secretary in consultation with the Prime Minister. The Director General is supported by a Legal Adviser and Secretariat, and by two Deputy Director Generals, one for Administration, and one for Operations. The latter is in charge of five intelligence branches: (i) Intelligence Resources and Operations; (ii) Counter Terrorism (International); (iii) Counter Terrorism (Irish and other domestic); (iv) Counter Espionage and Counter Proliferation; and (v) Counter Subversion. The Home Secretary's signed warrant is required before the Service can interfere with property or have letters or telephone calls intercepted.