The Master and Margarita is a satire of the Stalin period in the Soviet Union, which was established ten years before Bulgakov started to write the novel. In the late 1920s, the RAPP (Russian Association of Proletarian Writers), led by Leopold Averbakh, cracked down on literature and the arts. Bulgakov was one of the victims of the censorship, and even wrote a letter to Stalin asking to be allowed to leave the country because he could not survive if he could not write. Instead, Stalin reassigned him to the Moscow Art Theater, where he spent the end of his life as an assistant director and literary consultant.
Bulgakov worked on The Master and Margarita continuously from 1928 until his death in 1940, even dictating changes to his wife when he became too ill to write. His widow, Yelena Shilovskaya, preserved his work after his death. The Master and Margarita first appeared in the magazine Moskva in 1966.