Sergei V. Mikhalkov, a poet and writer who rose at the height of the Stalinist era to the apex of the Soviet literary hierarchy, eventually writing the lyrics to the Soviet and Russian national anthems, died in Moscow on Aug. 27 at the age of 96. Denis Baglai, a spokesman for one of Mikhalkov's sons, the Russian director Nikita Mikhalkov, confirmed the death, saying that Mikhalkov had long been ill with heart problems. A favorite of Stalin's, Mikhalkov spent most of his life using his words to undergird the authority of Soviet rule. He was also an expert in the vagaries of the fickle Soviet system. 'He compelled the Soviet regime to work for him,' said Viktor V. Erofeyev, a writer, whom Mikhalkov once helped to expel from the Soviet Writers Union. 'When all were slaves of the times, he was a master of the times.' Mikhalkov was born on March 13, 1913, in the waning days of Russia's czarist empire. A writer from a young age, he rose to fame quickly in the Soviet Union's early days, winning the prestigious Order of Lenin, among many awards. He became renowned throughout the Soviet Union and beyond for his children's literature, which remains popular among young Russians. In 1943, he was commissioned to write the lyrics of a new Soviet national anthem that would inspire his fellow Russians amid the horrors and privations of the war with Hitler's Germany. 'We were raised by Stalin with faith in the people,' goes a line from the anthem, written by Mikhalkov and the poet Gabriel El-Registan, and set to music by Aleksandr Aleksandrov. Mikhalkov never hid his respect for Stalin, recalling fondly in a 2008 interview having drunk with him until 5 in the morning the day after the new anthem was first performed. 'When people ask me who of the greatest people was the most interesting to converse with, I always answer: with Stalin,' he told the newspaper Argumenty i Fakty at the time. When the Kremlin requested a change to the lyrics in 1977, he dutifully complied. In 2000, he wrote new lyrics at the behest of Russia's new president, Vladimir V. Putin, who restored the booming Soviet melody thrown out 10 years earlier. Putin, now the prime minister, and Dmitri A. Medvedev, the president, both praised Mikhalkov on Aug. 27 and offered condolences to his family. He is survived by his second wife, Yulia Subbotina, a physicist; two children; 10 grandchildren; and eight great-grandchildren. His first wife, Natalia Konchalovskaya, died in 1988. His children, Nikita Mikhalkov and Andrei Konchalovsky -- who adopted his mother's surname -- are both prominent film directors. To his supporters, Mikhalkov was a living legend. 'Our country's history, its culture, the history of our literature -- that is Mikhalkov,' said Andrei D. Dementyev, a prominent Soviet-era poet and friend of Mikhalkov's. 'He was the voice of our country above all.' But he suffered harsh criticism later in life, especially after the fall of the Soviet Union, for his role in enforcing the pervasive censorship that stifled artistic expression under the Communist Party. He was part of a campaign to denounce the Nobel laureates Boris Pasternak and Aleksandr Solzhenitsyn, who was forced from the Soviet Union in 1974. For this, however, he was never apologetic. 'A person who lived through the Soviet epoch from beginning to end needs to be judged by the laws of that era,' he said in the 2008 interview. 'I am not ashamed of my work.' 