He was educated at Westminster School under Busby, who, as he afterwards said, was not only a master but a father to him, and in 1641 was elected to a scholarship at Trinity College, Cambridge, graduating M.A.
An ardent royalist he was chosen to preach the thanksgiving sermon for the Restoration at St. Mary's, Oxford, 27 May 1660, and afterwards published it under the title of 'David's Return from Banishment.'
He also published 'Votivum Carolo, or a Welcome to his sacred Majesty Charles II from the Master and Scholars of Woodstock School,' a volume of English and Latin verses composed by Gregory and his pupils.
Shortly afterwards he became head-master of a newly founded school at Witney, Oxfordshire, and 22 Sept. 1661 he was incorporated D.D.
He was appointed a chaplain to the King, and in 1671 was presented by Earl Rivers to the living of Hambleden, Buckinghamshire.