At first, it was only a bedtime story for her 2-year-old daughter. Judith Kerr’s husband, a screenwriter, was away on a film shoot, and the two of them were left at home, where they amused themselves with occasional trips to see the big cats at the zoo.

Thinking they could use a little company, Ms. Kerr began crafting a story of a friendly tiger who arrives at their home in London and joins them for tea — gulping it down straight from the kettle, devouring their sandwiches, buns, biscuits and cake, and drinking “all the water in the tap” before politely excusing himself to leave.

“Talk the tiger,” her daughter said each night, asking to hear the story once more.

Ms. Kerr later wrote down the bedtime tale, added brightly colored illustrations and at age 45 became a published author. Her 1968 debut, “The Tiger Who Came to Tea,” sold more than 5 million copies and made her one of the most beloved children’s writers in Britain, where reviewer Antonia Fraser called the volume “a dazzling first book” that would make children “scream with delicious pleasure at the dangerous naughtiness” of the plot.

But then, as adults sometimes do, her older readers began to see a far deeper, darker meaning in “The Tiger Who Came to Tea.” Ms. Kerr had arrived in England at age 12 as a refu­gee from Nazi Germany. Was the tiger a symbol for the Gestapo, the Nazi secret police force that she had evaded in her childhood? Did it represent the sexual revolution of the 1960s, or perhaps the countercultural movement sweeping through staid old England?

For decades, her response was always the same: No. The book was simply about a tiger who came to tea.

Ms. Kerr, who went on to write and illustrate a best-selling series about a forgetful cat named Mog, as well as a semiautobiographical children’s novel — “When Hitler Stole Pink Rabbit” — about her family’s World War II escape, was 95 when she died May 22 at her home in London. Her publisher, HarperCollins U.K., announced the death in a statement but did not give a precise cause.

Ms. Kerr (pronounced car) wrote more than 30 books that were translated into 20 languages and, in recent years, was an elegant and witty fixture of the English literary circuit. Her guiltiest pleasure, she told the Guardian one week before her death, was “drinking dregs of the whisky from the night before”; her biggest disappointment, she added, was “not having longer legs.”

Trained as an artist, she often spent months agonizing over her illustrations, redoing her ink work or erasing the lines of a colored pencil to precisely render the legs of a frog and the handlebars of a bicycle. She was frequently accompanied in her work by a succession of pet cats — notably the mischievous Mog, who sat on her lap, pushing the paintbrush with her nose, and delighted in licking the hair of Ms. Kerr’s sleeping daughter.

The cat was featured in more than a dozen books, beginning with “Mog the Forgetful Cat” (1970), Ms. Kerr’s second storybook. It was followed by a work for slightly older readers, “When Hitler Stole Pink Rabbit” (1971), inspired by a comment Ms. Kerr’s 8-year-old son made after watching “The Sound of Music”: “Now we know what it was like when Mummy was a little girl.”

“It was so different from the way they grew up that I wanted them to know about it,” she later said, “and I wanted also to explain that it wasn’t nearly as horrific as it sounded.”

Named for a favorite toy that Ms. Kerr left behind when she fled her home in Berlin, “Pink Rabbit” is often cited as a leading work of children’s literature about World War II, alongside volumes such as “Goodnight Mister Tom,” by Michelle Magorian, and “Carrie’s War,” by Nina Bawden.

The novel chronicled Ms. Kerr and her German-Jewish family’s journey from Nazi Germany to Switzerland, France and finally England, where they initially mistook railway-side advertisements for town names while taking the train to London. Why, Ms. Kerr wondered, did they keep passing the city of Bovril (a salty British meat extract)?

When her young protagonist, Anna, learns that the Nazis put a thousand-mark price on her father’s head, she imagines him being buried under “a terrible shower of heavy coins.” It was only in adulthood, Ms. Kerr said, that she began to understand the toll the war took on her parents, and to realize the danger they had faced.

Examining her father’s letters, she said she learned that her mother “never stopped talking about suicide” and had contemplated killing Ms. Kerr and her brother to keep them from falling into the hands of the Nazis.

Anna Judith Gertrud Kerr was born in Berlin on June 14, 1923. Her mother, the former Julia Weismann, was a composer and pianist; her father, Alfred Kerr, was a prominent essayist, critic and radio broadcaster with a socialist bent. Warned by a police officer that the authorities were planning to seize his passport, Alfred left the country abruptly in 1933.

Weeks later, he was followed by Ms. Kerr, her brother Michael and their mother, who met Alfred in Zurich on the night before the German elections that consolidated Hitler’s grip on power. The family arrived in London in 1936, and Ms. Kerr worked as a Red Cross secretary during the war. She received a scholarship in 1945 to study at the Central School of Arts and Crafts.

Ms. Kerr decorated children’s nurseries before joining the BBC in 1953 as a scriptwriter and editor, and soon met screenwriter Nigel Kneale, creator of the British television character Bernard Quatermass, at the network canteen.

They married in 1954, and he died in 2006. Survivors include their two children, Tacy Kneale, a painter and special-effects artist, and novelist Matthew Kneale, author of “English Passengers”; and two grandchildren.

Ms. Kerr wrote two sequels to her “Pink Rabbit” book, forming a coming-of-age trilogy known as “Out of the Hitler Time”: “Bombs on Aunt Dainty,” originally titled “The Other Way Round” (1975), and “A Small Person Far Away” (1978). She was appointed to the Order of the British Empire in 2012, “for services to children’s literature and Holocaust education.”

Her recent works included “My Henry” (2012), a gently humorous children’s book about life as a widow. “They think I’m sitting in this chair, just waiting for my tea,” she wrote. “In fact, I’m flying through the air with Henry holding me. My Henry died and went to heaven but now he’s got his wings.”

The book was far from Ms. Kerr’s first foray into writing about death for young readers. In 2002, while reflecting on her advanced age and mortality, she took the unusual step of killing off a popular children’s character, in the storybook “Goodbye Mog.” (He was resurrected in 2015 for “Mog’s Christmas Calamity,” which raised more than 1 million pounds for a children’s literacy campaign.)

“Mog was tired,” Ms. Kerr wrote, below an illustration that showed her former playmate curled up on a blue-check blanket, as his ghost rose peacefully into the air. “She was dead tired. Her head was dead tired. Her paws were dead tired. Even her tail was dead tired. Mog thought, ‘I want to sleep forever.’ And so she did. But a little bit of her stayed awake to see what would happen next.”