Image caption Alan Turing is credited with a key role in breaking wartime German codes

A last minute donation from the National Heritage Memorial Fund has saved the papers of the computing genius Alan Turing for the nation.

The collection of scientific papers and material relating to Turing's work on wartime codebreaking was in danger of going abroad.

He was one of the founding fathers of modern computing and a key figure in breaking the German Enigma code.

The National Heritage Memorial Fund's £200,000 donation filled the gap.

The papers were put up for auction last year and an internet campaign swung into action.

The aim was to save the papers for the museum at Bletchley Park in Buckinghamshire, where Turing worked breaking codes during the war.

IT journalist Gareth Halfacree managed to raise £23,000 from public donations.

Despite his stature amongst the technical community, I sense that the name Alan Turing is still not that widely known Rory Cellan-Jones, Technology correspondent Read Rory's thoughts in full

Internet search firm Google also pledged cash but the money raised was £200,000 short of the seller's reserve price.

The Fund says the papers will stand as a permanent memorial to a man who played a crucial role in the war.

Turing is famous for his code-breaking work at Bletchley Park during World War II, helping to create the Bombe machine which cracked messages enciphered using the German Enigma code.

He committed suicide in 1954 at the age of 41, two years after being prosecuted for having a sexual relationship with a man.

In 2009 thousands of people signed a Downing Street petition calling for a posthumous government apology to Turing.

Image caption Turing's Bombe machine is viewed by many as the progenitor of the modern computer

The then prime minister Gordon Brown responded by saying he was sorry for the "appalling" way Turing was treated for being gay.

Mr Halfacree told the BBC: "These papers are extremely significant."

During Turing's short life he only published 18 papers and offprints of 15 of them, which were given by Turing to his friend Professor Max Newman, are included in the collection.

Mr Halfacree said: "There are handwritten notes by Turing on them and one of them has the signature of his mother on it."