Born in Cape Town, Cape Province, Union of South Africa, on 9 February 1940 to Afrikaner parents, his father, Zacharias Coetzee, was an occasional lawyer and government employee, and his mother, Vera Coetzee (born Wehmeyer), a schoolteacher. The family spoke English at home, but J M spoke Afrikaans with other relatives. He is descended from early Dutch immigrants to South Africa in the 17th century, while his mother was a descendant of German and Polish immigrants.
Coetzee spent most of his early life in Cape Town and in Worcester in Cape Province (modern-day Western Cape) as recounted in his fictionalized memoir, Boyhood (1997). The family moved to Worcester when he was eight, after his father had lost his government job. He attended St. Joseph's College, a Catholic school in the Cape Town suburb of Rondebosch, later studying mathematics and English at the University of Cape Town and receiving his Bachelor of Arts with Honours in English in 1960 and his Bachelor of Arts with Honours in Mathematics in 1961.
He then relocated to the United Kingdom, in 1962, worked as a computer programmer for IBM in London, staying until 1965. In 1963, while still in the UK, was awarded a Master of Arts degree from the University of Cape Town for a thesis on the novels of Ford Madox Ford entitled "The Works of Ford Madox Ford with Particular Reference to the Novels" (1963). His experiences in England were later recounted in Youth (2002), his second volume of fictionalised memoirs.
Coetzee went to the University of Texas at Austin, in the United States, on the Fulbright Program in 1965. Receiving a PhD in linguistics there in 1969. His PhD thesis was on computer stylistic analysis of the works of Samuel Beckett and was entitled "The English Fiction of Samuel Beckett: An Essay in Stylistic Analysis" (1968). In 1968, he began teaching English literature at the State University of New York at Buffalo where he stayed until 1971. It was at Buffalo that he began his first novel, Dusklands. In 1971, he sought permanent residence in the United States, which was denied, due to his involvement in anti-Vietnam-War protests. In March 1970, he had been one of 45 faculty members who occupied the university's Hayes Hall and were subsequently arrested for criminal trespass. He then returned to South Africa to teach English literature at the University of Cape Town, where he was promoted Professor of General Literature in 1983 and was Distinguished Professor of Literature between 1999 and 2001. Upon retiring in 2002 and relocating to Adelaide, Australia, he was made an honorary research fellow at the English Department of the University of Adelaide, where his partner, Dorothy Driver, is a fellow academic, and served as professor on the Committee on Social Thought at the University of Chicago until 2003.