Thomas Gray was born on 26 December 1716 in Cornhill in London.  His father was a scrivener and his mother a milliner. He was the fifth of twelve children and the only one to survive.

With his father becoming mentally unwell and abusing his wife she left with Thomas in tow for a safer life.  Thomas was sent to Eton, where two of his uncles worked, and although he was a delicate and scholarly child with an aversion to sports he found it suited him.  Whilst there he made three close friends;  Horace Walpole, son of the Prime Minister Robert Walpole; Thomas Ashton, and Richard West. The four prided themselves on their style, humour, and appreciation of beauty. They were called the "quadruple alliance."  In 1734 Gray went up to Peterhouse, Cambridge. Although his family wished him to study law he spent most of his time reading classical and modern literature, and playing Vivaldi and Scarlatti on the harpsichord for relaxation.  In 1738 he accompanied his old school-friend Walpole on his Grand Tour of Europe. It was Walpole who later helped publish Gray's poetry.  Gray began to seriously write poems in 1742, mainly after his close friend Richard West died. He moved to Cambridge and began a programme of literary study. Gray was a brilliant bookworm, a quiet, abstracted, dreaming scholar. He became a Fellow first of Peterhouse, and later of Pembroke College where he had moved after the students at Peterhouse played a prank on him.

It is thought that Gray began writing his masterpiece, the Elegy Written in a Country Churchyard, in the graveyard of St Giles parish church in Stoke Poges, Buckinghamshire, in 1742. After several years of leaving it unfinished, he completed it in 1750. When Gray sent it to Walpole, Walpole sent off the poem as a manuscript and it appeared in many magazines. Gray then published the poem himself and received the credit he was due. The poem was a literary sensation. Its reflective, calm and stoic tone was greatly admired, and despite the piracy it was imitated, quoted and translated into Latin and Greek.

Gray spent most of his life as a scholar in Cambridge, and only travelled again later in life. Although he wrote little he is regarded by some as the foremost English-language poet of the mid-18th century. In 1757, he was offered the post of Poet Laureate, which he refused.

Gray was extremely self-critical and feared failure. He once wrote that he feared his collected works would be "mistaken for the works of a flea". Gray came to be known as one of the "Graveyard poets" of the late 18th century, along with Oliver Goldsmith, William Cowper, and Christopher Smart. Gray perhaps knew these men, sharing ideas about death, mortality, and the finality of death.

In 1768, after the death of Lawrence Brockett the Regius chair of Modern History at Cambridge, a sinecure which carried a salary of £400, fell vacant and Gray secured the position.

Thomas Gray died on 30 July 1771 in Cambridge, and was buried beside his mother in the churchyard of Stoke Poges, the setting for his famous Elegy.