Thomas Hardy was born on 2 June 1840 in Higher Bockhampton (then Upper Bockhampton), a hamlet in the parish of Stinsford to the east of Dorchester in Dorset, England, where his father Thomas (1811–1892) worked as a stonemason and local builder, and married his mother Jemima (née Hand; 1813–1904) in Beaminster, towards the end of 1839. Jemima was well-read, and she educated Thomas until he went to his first school at Bockhampton at the age of eight. For several years he attended Mr. Last's Academy for Young Gentlemen in Dorchester, where he learned Latin and demonstrated academic potential. Because Hardy's family lacked the means for a university education, his formal education ended at the age of sixteen, when he became apprenticed to James Hicks, a local architect.
Hardy trained as an architect in Dorchester before moving to London in 1862; there he enrolled as a student at King's College London. He won prizes from the Royal Institute of British Architects and the Architectural Association. He joined Arthur Blomfield's practice as assistant architect in April 1862 and worked with Blomfield on All Saints' parish church in Windsor, Berkshire, in 1862–64. A reredos, possibly designed by Hardy, was discovered behind panelling at All Saints' in August 2016. In the mid-1860s, Hardy was in charge of the excavation of part of the graveyard of St Pancras Old Church prior to its destruction when the Midland Railway was extended to a new terminus at St Pancras.
Hardy never felt at home in London, because he was acutely conscious of class divisions and his social inferiority. During this time he became interested in social reform and the works of John Stuart Mill. He was introduced by his Dorset friend Horace Moule to the works of Charles Fourier and Auguste Comte. Mill's essay On Liberty was one of Hardy's cures for despair, and in 1924 he declared that "my pages show harmony of view with" Mill. He was also attracted to Matthew Arnold's and Leslie Stephen's ideal of the urbane liberal freethinker.
After five years, concerned about his health, he returned to Dorset, settling in Weymouth, and decided to dedicate himself to writing.
In 1870, while on an architectural mission to restore the parish church of St Juliot in Cornwall, Hardy met and fell in love with Emma Gifford, whom he married in Kensington in late 1874. renting St David's Villa, Southborough (now Surbiton) for a year. In 1885 Thomas and his wife moved into Max Gate in Dorchester, a house designed by Hardy and built by his brother. Although they later became estranged, Emma's subsequent death in 1912 had a traumatic effect on him and after her death, Hardy made a trip to Cornwall to revisit places linked with their courtship; his Poems 1912–13 reflect upon her death. In 1914, Hardy married his secretary Florence Emily Dugdale, who was 39 years his junior. He remained preoccupied with his first wife's death and tried to overcome his remorse by writing poetry. In his later years, he kept a Wire Fox Terrier named Wessex, who was notoriously ill-tempered. Wessex's grave stone can be found on the Max Gate grounds. In 1910, Hardy had been appointed a Member of the Order of Merit and was also for the first time nominated for the Nobel Prize in Literature. He was nominated again for the prize 11 years later.
Hardy's interest in the theatre dated from the 1860s. He corresponded with various would-be adapters over the years, including Robert Louis Stevenson in 1886 and Jack Grein and Charles Jarvis in the same decade. Neither adaptation came to fruition, but Hardy showed he was potentially enthusiastic about such a project. One play that was performed, however, caused him a certain amount of pain. His experience of the controversy and lukewarm critical reception that had surrounded his and Comyns Carr's adaptation of Far From the Madding Crowd in 1882 left him wary of the damage that adaptations could do to his literary reputation. So it is notable that, in 1908, he so readily and enthusiastically became involved with a local amateur group, at the time known as the Dorchester Dramatic and Debating Society, but that would become the Hardy Players. His reservations about adaptations of his novels meant he was initially at some pains to disguise his involvement in the play. However, the international success of the play, The Trumpet Major, led to a long and successful collaboration between Hardy and the Players over the remaining years of his life. Indeed, his play The Famous Tragedy of the Queen of Cornwall at Tintagel in Lyonnesse (1923) was written to be performed by the Hardy Players.
Hardy was horrified by the destruction caused by the First World War, pondering that "I do not think a world in which such fiendishness is possible to be worth the saving" and "better to let western 'civilization' perish, and let the black and yellow races have a chance." He wrote to John Galsworthy that "the exchange of international thought is the only possible salvation for the world."
Hardy became ill with pleurisy in December 1927 and died at Max Gate just after 9 pm on 11 January 1928, having dictated his final poem to his wife on his deathbed; the cause of death was cited, on his death certificate, as "cardiac syncope", with "old age" given as a contributory factor. His funeral was on 16 January at Westminster Abbey, and it proved a controversial occasion because Hardy had wished for his body to be interred at Stinsford in the same grave as his first wife, Emma. His family and friends concurred; however, his executor, Sir Sydney Carlyle Cockerell, insisted that he be placed in the abbey's famous Poets' Corner. A compromise was reached whereby his heart was buried at Stinsford with Emma, and his ashes in Poets' Corner. Hardy's estate at death was valued at £95,418 (equivalent to £5,900,000 in 2020).
Shortly after Hardy's death, the executors of his estate burnt his letters and notebooks, but twelve notebooks survived, one of them containing notes and extracts of newspaper stories from the 1820s, and research into these has provided insight into how Hardy used them in his works. In the year of his death Mrs Hardy published The Early Life of Thomas Hardy, 1841–1891, compiled largely from contemporary notes, letters, diaries, and biographical memoranda, as well as from oral information in conversations extending over many years.
Hardy's work was admired by many younger writers, including D. H. Lawrence, John Cowper Powys, and Virginia Woolf. In his autobiography Goodbye to All That (1929), Robert Graves recalls meeting Hardy in Dorset in the early 1920s and how Hardy received him and his new wife warmly, and was encouraging about his work.
Hardy's birthplace in Bockhampton and his house Max Gate, both in Dorchester, are owned by the National Trust.