As Greece’s most illustrious composer, Mr. Theodorakis wrote symphonies, operas, ballets, film scores, music for the stage, marches for protests and songs without borders — an oeuvre of hundreds of classical and popular pieces that poured from his pen in good times and bad, even in the confines of drafty prison cells, squalid concentration camps and years of exile in a remote mountain hamlet.

He also wrote anthems of wartime resistance and socialist tone poems about the plight of workers and oppressed peoples. His most famous work on political persecution was the haunting “Mauthausen Trilogy,” named for a World War II Nazi concentration camp used mainly to exterminate the intelligentsia of Europe’s conquered lands. It has been described as the most beautiful music ever written on the Holocaust.

Mr. Theodorakis’s music made him a wealthy Communist. Having paid his dues to society, he did not apologize for his privileged life as a member of Parliament, with homes in Paris, Athens and the Greek Peloponnesus; for being feted at premieres of his work in New York, London and Berlin; or for counting cultural and political leaders in Europe, America and the Middle East as friends.

During World War II, he joined a Communist youth group that fought fascist occupation forces in Greece. After the war, his name appeared on a police list of wartime resisters, and he was rounded up with thousands of suspected Communists and sent for three years to the island of Makronisos, the site of a notorious prison camp. There he contracted tuberculosis, and he was tortured and subjected to mock executions by being buried alive.

Mr. Theodorakis studied at music conservatories in Athens and Paris in the 1950s, writing symphonies, chamber music, ballets and assorted rhapsodies, marches and adagios. He set to music the verses of eminent Greek poets, many of them Communists. He also deepened his ties to Communism: When Greece became a Cold War battleground, he blamed not Stalin but the C.I.A.

He was profoundly affected by the assassination in 1963 of Grigoris Lambrakis, a prominent antiwar activist, who was run down by right-wing zealots on a motorcycle at a peace rally in Thessaloniki. His murder — a pivotal event in modern Greek history that was portrayed in thinly fictionalized form in the Costa-Gavras film as the work of leaders of the subsequent junta — provoked mass protests and a national political crisis.