Miroslav Krleža was born in Zagreb, modern-day Croatia. He entered a preparatory military school in Pécs, modern-day Hungary. At that time, Pécs and Zagreb were within the Austro-Hungarian Empire. Subsequently, he attended the Ludoviceum military academy at Budapest. He defected for Serbia in 1912 as a volunteer for the Serbian army, but was dismissed as a suspected spy. Upon his return to Croatia, he was demoted in the Austro-Hungarian army and sent as a common soldier to the Eastern front in the World War I. In the post-WWI period Krleža established himself both as a major Modernist writer and politically controversial figure in Yugoslavia, a newly created country which encompassed South Slavic lands of former Habsburg Empire and the kingdoms of Serbia and Montenegro.
Krleža was the driving force behind Leftist literary and political reviews Plamen (1919), Književna republika (1923–1927), Danas (1934) and Pečat (1939–1940). He was a member of the Communist Party of Yugoslavia from 1918, expelled in 1939 because of his unorthodox views on art, his defense of artistic freedom against Socialist realist doctrine, and his unwillingness to give an open support to Stalin's purges, after the long polemic now known as "the Conflict on the Literary Left", lead between Krleža and virtually every important writer in the mid-war Yugoslavia. The Party commissar sent to intermediate between Krleža and other Leftist and Party journals was Josip Broz Tito. After the establishment of the pro-Nazi puppet Independent State of Croatia, Krleža refused to join the Partisans now headed by Tito. It is believed that Krleža made that decision after learning of what happened to his associate August Cesarec in the Kerestinec incident, fearing the possible revenge from his former Party colleagues. Krleža spent the war period in Zagreb, marginalized by the Nazi government as he refused their calls for cooperation. During these years he kept silent, not publishing at all or making public appearances.
Following a brief period of social stigmatization after 1945 - during which he nevertheless became very influential vice-president of Yugoslav Academy of Science and Arts in Zagreb, while Croatia's central state publishing house, Nakladni zavod Hrvatske, published his collected works - Krleža was rehabilitated after Yugoslavia's break-up with Stalin's SSSR, while his position on art and literature even became the official one. Still, Milovan Đilas publicly defended Party's pre-war position against Krleža, declaring that his magazine Pečat worked from the revisionist positions, but on Tito's intervention, "the Conflict on Literary Left" was officially closed and Đilas' speech was regarded as the personal opinion, and wasn't printed in the proceedings from Party's 1948 congress.
Supported by Tito, in 1950 Krleža founded the Yugoslav Institute for Lexicography, now called Lexicograpcial Institute Miroslav Krleža, holding the position of its head until the death. From then on, he led a life of the high-profile writer and intellectual, often closely connected to President Tito. Krleža also shortly held the post of the president of Yugoslav writers' union between 1958 and 1961. In 1962 he received the NIN award for the novel Zastave, and in 1968 the Herder Prize.
Following the deaths of Tito in May 1980, and particularly of Krleža's wife Bela Krleža in April 1981, Krleža spent most of his last year of life depressed and ill. He was awarded Laureate Of The International Botev Prize in 1981. He died in his villa Gvozd in Zagreb, on December 29, 1981, at 1 am, and received a state funeral in Zagreb on January 4, 1982. Gvozd is now his memorial center.