According to Jon Stallworthy, Louis MacNeice wrote The Sunlight on the Garden as a "love-song" for his first wife, Mary Ezra, shortly after their divorce was finalised in November 1936.[3] Mary had left MacNeice for Charles Katzman in November 1935, and she followed Katzman to America early the next year. MacNeice was initially "devastated".[4] However, by the time the divorce was finalised, MacNeice was able to contemplate the end of his marriage with acceptance (as in the first stanza of The Sunlight on the Garden) and to remember his time with Mary with gratitude (as in the last stanza). At the same time that MacNeice wrote The Sunlight on the Garden he was collaborating with W. H. Auden on Letters from Iceland, and in Last Will and Testament from Letters from Iceland MacNeice shows a similar spirit of generosity towards Mary:
Lastly to Mary living in a remote
Country I leave whatever she would remember
Of hers and mine before she took that boat,
Such memories not being necessarily lumber
And may no chance, unless she wills, delete them
And may her hours be gold and without number.[5]
On 6 November 1936, four days after the divorce was finalised, MacNeice moved into a flat at 4 Keats Grove, Hampstead, London. (The previous occupant of the flat was the poet and critic Geoffrey Grigson, and the flat was just fifty yards along the road from Keats House, the house once occupied by the poet John Keats). The Sunlight on the Garden was written while MacNeice was living at 4a Keats Grove, and as Jon Stallworthy notes, 4a was a 'garden flat'; "the three principal rooms of the flat faced south and, even in November, were lit by the low sun striking through the branches of two large sycamores at the back of the garden.".[6] Stallworthy associates The Sunlight on the Garden with the garden of 4 Keats Grove and other gardens MacNeice had known, going back to the garden at Carrickfergus Rectory where MacNeice had spent his childhood.