The public had already donated £28,500 to prevent the papers being sold to a private collector, with Google pledging $100,000. But further funds were needed to reach the asking price until the NHMF made its donation.

Alan Turing is best known for being the father of modern computer science and his work at Bletchley Park conceiving the Turing-Welchman Bombe to mechanise the process of breaking the German Enigma cipher.

The collection includes offprints of sixteen of Turing's eighteen published works including his famous paper On Computable Numbers.

Dame Jenny Abramsky, Chair of the NHMF, said: "This is such welcome news. Alan Turing was a true war hero and played an absolutely crucial role during the Second World War."

Peter Barron, director of external relations for Google, said: "Turing is a hero to many of us at Google for his pioneering work on algorithms and the development of computer science. We're delighted this important collection will now be accessible to everyone visiting Bletchley Park."

Sue Black, research associate at the Department of Computer Science at University College London, has spearheaded the campaign to keep the Turing papers in the UK. "This is really important news for the next generation, as Turing is such a good role models for kids getting into IT. His story is one that has really captured the public imagination," she said.

Simon Greenish, CEO of the Bletchley Park Trust, says he is delighted to have the collection here at Bletchley Park: "This is surely its most fitting home and it will be an incredible addition to the visitor experience," he added.

Historians agree that Bletchley Park, top-secret codebreaking hub of World War Two, shortened the war by at least two years, saving countless lives. Since 1994, it has been open to the public as a museum.

In September 2009, following a public campaign, the PM Gordon Brown issued an apology for how Turing had been treated as a result of his homosexuality. "On behalf of the British government, and all those who live freely thanks to Alan's work, I am very proud to say: we're sorry, you deserved so much better," he said.

This story was first published by Computer Weekly