Gray was born in York. He went to St Peter's School in York, and Trinity College, Cambridge. From 1883 to 1893, he was Director of Music at Wellington College, Berkshire. In 1893, when Stanford left the post of organist at Trinity College, Alan went back there to become organist, and stayed there until 1930.