Sergei Mikhalkov, who has died aged 96, was a Soviet children's author, poet and writer of satirical fables. He is best known for writing three different versions of the Soviet and Russian national anthems to suit the diverse tastes of Josef Stalin, Leonid Brezhnev and Vladimir Putin. But it is with his verses for children – loved by many generations of Soviet boys and girls – that he achieved his most enduring success.

In Uncle Styopa – a friendly policeman always ready to rescue cats stuck up trees, and to perform other helpful deeds, about whom Mikhalkov wrote a series of poems – he created one of the best-loved characters of Russian children's literature. Like Mikhalkov, the fictional Styopa was exceptionally tall. (On entering a cinema, a group of children complain he is blocking their view of the screen, telling him: "You, comrade, sit on the floor/It's all the same to you.") In English, his name translates as Uncle Steeple.

Mikhalkov's poems were simple, easy to learn by heart, and, from the 1930s onwards, ended up on almost every Soviet bookshelf. But he was also prepared to put his literary talents to the service of the state.

Mikhalkov was born into an aristocratic Moscow family. His father Vladimir noticed his son's talent at an early age, sending some of nine-year-old Sergei's verses to an established poet, who responded encouragingly. Mikhalkov published his first poem, Road, aged 15. After finishing school, he worked in a Moscow loom factory, before joining the staff of the newspaper Izvestiya. His poems appeared in communist magazines for children, and other journals.

He first attracted Stalin's attention in 1935, after he wrote a poem entitled Svetlana, the name of Stalin's daughter. By 1939, and with Uncle Styopa a national bestseller, the 26-year-old Mikhalkov scooped the Order of Lenin and the Stalin prize.

In 1943 he and the Armenian poet Gabriel El-Registan jointly entered a competition to write a new Soviet national anthem. Stalin picked their version from 60 others, making only minor alterations in soft pencil. As the Red Army fought back against the invading Nazis in 1944, Mikhalkov's patriotic ode replaced the Internationale as the Soviet Union's official wartime hymn. Inevitably, it included a line praising Stalin, "who brought us up", for labour and heroic deeds.

By the postwar 1950s, Mikhalkov had become one of the regime's favourite courtier-poets. His work appeared frequently on the front page of Pravda – praising a new mega-watt power-station, or some other example of Soviet technological prowess, or lambasting Clement Attlee and Harry Truman. The result was sometimes little more than communist doggerel. One line read: "It stands powerful and strong, and works on nuclear energy." Mikhalkov joined the prestigious Soviet Writers' Union in 1938, and rose rapidly.

In 1958 he took the side of the state in the campaign against Boris Pasternak, comparing Pasternak with an unwanted plant that grows in your kitchen garden. He also participated in the later campaign against Alexander Solzhenitsyn.

After Stalin's death, and under Khrushchev, Mikhalkov's words for the national anthem were no longer used. For 20 years, the anthem was played without words. A solution was found in the 1970s, when Mikhalkov wrote new lyrics omitting all reference to Stalin, but keeping mentions of Lenin.

In the late Soviet Brezhnev period, he achieved popularity among a new generation via Fitil (The Fuse), a series of short humorous films that poked fun at everyday Soviet life. Shown before the main feature, these mild, politically harmless satires were preferred to the alternative – the propaganda-style News of the Day. He also wrote satirical plays.

After the Soviet Union's collapse, Boris Yeltsin dumped the old Soviet anthem. In 2000, however, Yeltsin's ambitious KGB successor Putin brought it back again, asking Mikhalkov, then aged 87, to write another version. He did, this time praising Russia as a "sacred state" and "Our dear land kept safe by God". In an interview in 2000 he said he had believed in God all along. Mikhalkov was an avid collector of state awards: he received the Stalin prize three times. In 2005 Putin bestowed upon Mikhalkov the Order of St Andrew, Russia's highest award, for his services to literature.

He is survived by his physicist wife Yulia Subbotina, his two sons Nikita Mikhalkov and Andrei Konchalovsky, both successful film directors, 10 grandchildren and eight great-grandchildren.

• Sergei Vladimirovich Mikhalkov, writer, born 13 March 1913; died 27 August 2009

Sign up for the Guardian Today

Our editors' picks for the day's top news and commentary delivered to your inbox each morning.