Mavis Batey was a garden historian and conservationist, but unknown to many until recently, was also one of the leading female Bletchley Park codebreakers whose skills in decoding the German Enigma ciphers proved decisive at various points of the war. On the outbreak of war she broke off her German studies to enlist as a nurse, but was told she would be more use as a linguist. She had hoped to be a Mata Hari-esque spy, seducing Prussian officers, but, she said, “I don’t think either my legs or my German were good enough, because they sent me to the Government Code & Cipher School.”

Batey was the last of the Bletchley “break-in” experts – codebreakers who cracked new codes and ciphers. She unravelled the Enigma ciphers that led to victory in the Battle of Cape Matapan in 1941, the Navy’s first fleet action since Trafalgar, and played a key role in breaking the astonishingly complex Abwehr (German secret service) Enigma. Without this, the Double Cross deception plan which ensured the success of D-Day could not have gone ahead.

Born in Dulwich, south-east London, in 1921, Mavis Lilian Lever was the daughter of a postal worker and a seamstress. The family holidayed annually in Bournemouth, but on passing “O” Level German, she persuaded her parents to take her to the Rhineland, which was to spark her interest in the country. She was reading German romanticism at University College London when war broke out. Recruited to the government agency, she worked briefly in London checking the personal columns of The Times for coded messages. Having shown promise, she was sent to Bletchley Park to work with Alfred “Dilly” Knox, whose research unit led the way in breaking Enigma. When she arrived, he greeted her with the words, “Hello, we’re breaking machines. Have you got a pencil? Here, have a go.” After his initial success with Enigma, Knox, the archetypal British eccentric, was working on new, and as yet uncracked, variants.

Download the new Independent Premium app Sharing the full story, not just the headlines

Batey began working on the updated Italian Naval Enigma machine, checking all new traffic and even the wheels, cogs and wiring to see how it was constructed. She reconstructed the wiring from the machine to discover a major machine flaw that helped her team break even more coded messages. “You had to work it all out yourself from scratch,” she recalled, “but gained the ability to think laterally.” In March 1941 she deciphered a message, “Today’s the day minus three,” which told them that the Italian Navy was up to something.

Batey and her colleagues worked for three days and nights until she decoded “a very, very long message” detailing the Italian fleet’s proposed interception of a British supply convey en route from Egypt to Greece; it included their plan of attack, strength – cruisers, submarines – locations and times. “It was absolutely incredible that they should spell it all out,” she recalled. The message was passed to Admiral Andrew Cunningham, commander of the Mediterranean Fleet, giving him the intelligence he needed to intercept the Italians.

He deceived the Japanese consul in Alexandria, who was passing information to the Germans, into thinking he was having the weekend off to play golf. Then under cover of darkness he set sail with three battleships, four cruisers and an aircraft carrier. Over 27-28 March 1941, his forces staged a series of surprise attacks. The Italians lost three cruisers, two destroyers and 3,000 sailors in the Battle of Matapan, never again dared to sail close to the Royal Navy. Cunningham went to Bletchley to thank Knox’s unit, ISK (Intelligence Section Knox).

Arguably, ISK’s most important coup was to break into the Enigma cipher. MI5 and MI6 had captured and identified most of Germany’s spies in Britain and in neutral Lisbon and Madrid, and had “turned” them, using them to feed false information to Germany about the Allies’ proposed invasion of France, in an operation known as the Double-Cross System.

However, no one knew if the Germans believed the intelligence, because Enigma had proven unbreakable. This machine had many millions of settings, as it used four rotors, rather than the usual three, which rotated randomly with no predictable pattern.

Working with Knox and Margaret Rock, Batey tested out every possibility, and in December 1941 broke a message on the link between Berlin and Belgrade, making it possible to reconstruct one of the rotors. Within days, ISK had broken the Enigma – and days later Batey cracked a second Abwehr cipher machine, the GGG, which confirmed that Germany believed the Double Cross intelligence.

British agents fed a stream of false intelligence to German command, convincing it that a US Army group was forming in East Anglia and Kent. Hitler believed the main invasion force would land at Pas-de-Calais rather than in Normandy, leading him to retain two key armoured divisions there. Montgomery’s head of intelligence, Brigadier Bill Williams, later said that without the deception, the Normandy invasion could well have been a disaster.

Mavis married Keith Batey, one of the Bletchley “break-in” experts, after he helped her with a particularly difficult problem. She recalled, “Dilly made no objections to my having sought such help and when I told him I was going to marry the ‘clever mathematician from hut 6’ he gave us a lovely wedding present.”

After the war she launched herself into researching landscape and garden history. She became the driving force behind moves by the Campaign to Protect Rural England, English Heritage and the Garden History Society to preserve historical gardens. She was the latter’s president from 1985 until her death. It was not until the 1970s that the couple were able to tell their own children about their codebreaking. She remarked that her children had always wondered why she was so good at Scrabble.

She was awarded the Royal Horticultural Society’s Veitch Memorial Medal in 1985, and appointed MBE for her conservation of historic gardens. Her books included Jane Austen and the English Landscape (1996); Alexander Pope: Poetry and Landscape (1999); and an affectionate biography of Knox, Dilly: The Man Who Broke Enigmas (2011). In 2001, she advised Kate Winslet on what it was like to be a female codebreaker, for the film Enigma.

Mavis Lilian Lever, codebreaker and conservationist: born London 5 May 1921; MBE 1987 married 1942 Keith Batey (died 2010; two daughters, one son); died 11 November 2013.