Nearly 60 years after his death, Alan Turing, the British mathematician regarded as one of the central figures in the development of the computer, received a formal pardon from Queen Elizabeth II on Monday for his conviction in 1952 on charges of homosexuality, at the time a criminal offense in Britain.

The pardon was announced by the British justice secretary, Chris Grayling, who had made the request to the queen. Mr. Grayling said in a statement that Mr. Turing, whose most remarkable achievement was helping to develop the machines and algorithms that unscrambled the supposedly impenetrable Enigma code used by the Germans in World War II, “deserves to be remembered and recognized for his fantastic contribution to the war effort and his legacy to science.”

The British prime minister, David Cameron, said in a statement: “His action saved countless lives. He also left a remarkable national legacy through his substantial scientific achievements, often being referred to as the ‘father of modern computing.’ ”