In the aggregate, World War II was one of the closest conflicts of the modern era. There were many instances where there would have been, had the circumstances been different, an Axis victory instead of an Allied one. In this context, intelligence played a crucial role in the outcome of the war.
The most significant success story in British intelligence during the Second World War was Ultra. Ultra was the British term given to the information derived from encrypted radio messages used by the Germans during the Second World War.  From the Spring of 1940 to the end of the war, the British were deciphering these messages, sometimes before those for whom the information was intended. With this ability in effect to read the enemy’s mind, Ultra might have actually won the war for the Allies. 
Before I begin to discuss Ultra’s contributions, however, I first must write about Ultra and its history. All German radio messages that were deciphered by the British were sent on a mechanical device known as the Enigma machine. This machine looked and seemed to operate like an ordinary typewriter. Yet, despite an appearance of simplicity, it was capable of creating over 5,000 billion trillion trillion trillion trillion (or 5,000 followed by 84 zeros) possible codes. 
One of the more interesting things about the Enigma machine is that it was originally sold on the commercial market. In 1919, a Dutch inventor named Hugo Alexander Koch acquired a patent for an invention, which he called the “Geheimschrijfmachine” or “secret writing machine.”  Four years later, he sold the patent to Dr. Arthur Scherbius, a German engineer, who further improved upon the machine. The improved product was named Enigma.
The German armed forces became interested during the 1920s in a machine like Enigma. Germany’s defeat in World War I convinced many that the German military codes were not entirely safe. In addition, the German armed forces were rearming above the restrictions imposed by Versailles. They needed a secret, totally secure method of communication.  A machine that purported to be a “secret writing machine” was seen as attractive.
The German Navy began to use the Enigma machine for its communications in 1926.  Throughout the rest of the 1920s and the beginning of the 1930s, the other remaining German agencies, both military and civilian, also switched. By the time Adolf Hitler rose to power, the Germans had a sizable advantage in military communications, an advantage that helped the Third Reich immensely. 
The Germans kept changing the Enigma machine throughout the 1930s. By 1939, the machine was many times more advanced than it had been during the 1920s. It is this machine that I will now describe, since it was the machine that the British ultimately mastered.
The Enigma Machine
The machine had four components: a keyboard, a lampboard, a scrambler unit, and internal wiring. The keyboard looked like that of a typewriter, except without numbers or punctuation. Corresponding to this keyboard was a lampboard, with each letter represented by a lamp. When sending a message one would first type it on the keyboard. A short time later, the message would light up on the lampboard, encoded.
The keyboard and the lampboard are, however, at the beginning and the end of the process, respectively. As each key is pressed, an electro-magnetic current is activated. This current is then sent through the scrambler unit, which consists of three removable wheels or rotors. Each of the wheels have knobs on their sides known as Umkehrwalze. These would be set to a particular letter, which would determine the code of the scrambler unit. When the current is finished going through the three wheels, it would go through the internal wiring of the machine, otherwise known as the Steckerboard. From there, it would light up the lampboard with the encoded text. 
This is a simple explanation of how the machine worked. The Germans did, however, complicate it further. They added two more wheels for a total of five, of which only three were used at any one time. The wheels could be arranged in any order, further complicating things. With all this complexity, the machine was able to create an infinite amount of codes. For perhaps justified reasons, the Germans considered the machine fool-proof.
Facing German intelligence with its confidence in the Enigma machine was a British organization equally confident that anything created by man could also be broken by man.  During the First World War, the Admiralty’s Room 40 had broken a number of German codes, including that used in the famous Zimmermann Telegram.  As a result, Room 40 was transformed into the Government Code and Cypher School (GC & CS) in 1920. Throughout the 1920s and 1930s, GC & CS recruited heavily from the universities, mainly Cambridge and Oxford, and formed useful contacts with many leading mathematicians and linguists. One month before war was declared [in Sept. 1939], GC & CS relocated from Whitehall [London] to a country estate 50 miles northwest, known as Bletchey Park.  From this location it would manage to break the Enigma codes from 1940 until the end of the war. How this was done is an interesting story, one that I will turn to now.
Breaking the Code
Every time a German cipher clerk sent out a message, it contained a preamble which included the wheel settings. This would be used by another clerk to properly set his machine. As soon as this was done, the message became readable. Once the preamble’s significance became understood by the British, deciphering was possible. Since there were an infinite amount of possible codes, however, a manual check on all would have been impossible. To combat this problem, Alan Turing and Gordon Welchman developed the Turing bombe.
The Turing bombe was in many ways the first computer.  It was based on the mathematical concept of reductio ad absurdum.  Simply put, one would make an initial assumption of what the wheel order and settings were, and then run a test. If the test failed, the assumption was proved wrong. One would keep repeating the process until an assumption was eventually proved right.
Ronald Lewin wrote in his Ultra Goes To War, that the “essential value” of the bombes, “was their ability to explore electro-magnetically a range of alternative possibilities at speeds far beyond the pace of human thought.”  As a result, the Allies were able to break the Enigma machine’s security. They were also helped by persistent sloppiness on the part of many of the German cipher clerks.
One example of sloppiness included using actual German words such as “ist” for the wheel settings, which was expressly forbidden under the “rules.”  Another more prevalent example of sloppiness was the use of “cribs,” or the same words, continuously in a message. This was especially so with weather reports and addresses. Once these cribs became known, it became easy to eliminate many of the possible codes before using the bombe. Thus, the Germans, but not entirely following the rules that they put in place, made Bletchey Park’s task much easier. 
-  Ronald Lewin, Ultra Goes To War, (NY: McGraw-Hill, 1978), pp. 63-64.
-  F.W. Winterbotham, The Ultra Secret, (NY: Harper and Row, 1974), p. 191.
-  Christopher Andrew and David Dilks, ed., The Missing Dimension, (London: Macmillan, 1984), p. 126, quoting Joseph Garlinski, Intercept: The Enigma War, (London: Methuen, 1979), p. 23.
-  Lewin, p. 25.
-  Ibid., p. 26.
-  Peter Calvocoressi, Top Secret Ultra, (Hong Kong, China: Cassell, 1980), p. 23.
-  Lewin, p. 26.
-  Gordon Welchman, The Hut Six Story, (NY: McGraw-Hill, 1982), pp. 35-52, passim.
-  Winterbotham, p. 16.
-  David Kahn, The Codebreakers, (NY: Macmillan, 1967), pp. 282-97, passim.
-  Lewin, pp. 51-52.
-  Andrew and Dilks, p. 136.
-  Welchman, p. 299.
-  Lewin, p. 119.
-  Calvocoressi, p. 50.
-  Ibid., pp. 50-52.