Before the publication of her novel Hamnet Maggie O’Farrell took a vintage dress she had bought for its London launch to an Edinburgh dry cleaners. By the time it was ready for collection the party had been canceled and the world had gone into lockdown.

“Within a week everything had changed,” she recalls. Her agent telephoned. “I remember her saying: ‘It’s not going to be what we hoped. Bookshops are shutting, Amazon isn’t shipping books any more. I guess we’ve always got the paperback.’”

O’Farrell, 50, wears an ironic, amused smile as she recounts this. “Compared to what else was going on, it was the world’s teeniest violin. Even I was more preoccupied with running a home school and restaurant for three hungry children than what was happening with my novel.”

As millions of devoted readers know, big things did, however, happen for Hamnet. Her historical novel tenderly imagines the plague death of Shakespeare’s only son, and his mother Agnes’s fathomless grief. A pandemic tale (one arresting stand-alone chapter describes the contagion’s passage from Alexandria to Venice, London and eventually Stratford), Hamnet became the word-of-mouth literary hit of lockdown and winner of the 2020 Waterstones book of the year and the Women’s Prize for Fiction. Steven Spielberg’s Amblin Entertainment and Hera Pictures are producing the film adaptation.

Meanwhile, fans’ appetites should be whetted by O’Farrell’s latest opulently atmospheric historical novel, The Marriage Portrait. Its setting is Renaissance Italy, her subject Lucrezia de’ Medici, married dynastically at 13 to Alfonso, Duke of Ferrara, and dead by 16. As with Hamnet, O’Farrell writes in an intimate continuous present third person. From the first paragraph the reader is on alert, warned that this may be the chronicle of a death foretold. Alfonso has brought Lucrezia to a remote hunting lodge. “It comes to her with a peculiar clarity … that he intends to kill her.”

A pandemic tale, Hamnet became the word-of-mouth literary hit of lockdown.

I meet O’Farrell in Edinburgh, outside an artisanal Swedish bakery. She is instantly, distinctively recognizable, with her wild auburn Clara Bow bob and vermilion-painted lips.

Her inspiration was Robert Browning’s poem My Last Duchess. A dramatic monologue, it describes a duke, identified as “Ferrara”, showing an emissary of his future wife the portrait of his last, and revealing more than was intended (“That’s my last Duchess painted on the wall/ Looking as if she were alive”).

O’Farrell found herself wondering if the poem was based on real characters. Soon a search revealed the gothic rumor that Alfonso had, Bluebeard-style, done away with his young wife. And as O’Farrell looked up Lucrezia, Bronzino’s extraordinary, almost photo-real portrait began to download. “Slowly, first the forehead, then the eyes. As soon as I saw it, I knew at a sort of cellular level: ‘This is my next book.’”

In truth, it is at least as likely that Lucrezia died of tuberculosis as at the hands of her husband. O’Farrell was at first determined to be even-handed. Then she read of Ferrara’s cruelty to his sisters: one was forced to watch her lover being strangled. “I thought: ‘Right, the gloves are off, Alfonso.’ For 400 years this girl has been silent, and silenced. Let’s bring her out from behind the duke’s curtain.”

What to make of O’Farrell having spent lockdown writing about uxoricide? Her husband is the author William Sutcliffe, whom she met at the University of Cambridge. She laughs. “I have no experience of uxoricide, but certainly, the novel’s sense of confinement felt very informed.”

For O’Farrell, Lucrezia’s gilded cage became “an incredible escape hatch”. There was one day when, maddened by persistent home school requests, she hid with her laptop in her daughter’s “unergonomic” Wendy house. “But generally, during that time, I could just about hold my sanity together if I could spend an hour or two a day in Renaissance Florence or Ferrara. It was, literally, armchair travel.”

The Marriage Portrait’s setting is Renaissance Italy, its subject Lucrezia de’ Medici, married dynastically at 13 and dead by 16.

O’Farrell was born in Northern Ireland to parents who had met at Trinity College Dublin. Her father’s academic career took them to Wales, then Scotland, and she is a seasoned traveler, who has previously been insistent on never using locations unfamiliar to her. Florence she knew: when her son, now 19, was “tiny” the family lived in Lucca, Tuscany. “But I had never set foot in Emilia-Romagna,” she says.

In September, when travel to Italy was easier, she visited Florence and Ferrara. “You form such an emotional bond with a character. I hadn’t known how powerful it would be, after spending a year living alongside Lucrezia, to go to where she lived, then died.”

The Marriage Portrait is O’Farrell’s ninth novel. Her best-selling 2018 memoir I Am, I Am, I Am was subtitled Seventeen Brushes with Death. These included the childhood encephalitis that left her bedbound for a year (Jimmy Savile once paid her a visit in hospital; thankfully a duty nurse refused to leave the room). She also writes movingly about her miscarriages and IVF. Most searing is the chapter on her eldest daughter’s anaphylaxis, an immunology disorder that means she is dangerously prone to severe allergic reactions. Shielding is not a new concept to this family.

Will O’Farrell now stick with historical fiction? “Whenever you start a book there’s a sense of vertigo, a bridge to be gapped between your everyday quotidian life and the one you are writing. In those two years I didn’t want to write a contemporary book because I had no idea what the world was going to be when we came out.” Reassuringly, perhaps, her next novel is set within “living memory”, and it has already necessitated a trip to Paris.

Her family moved to Edinburgh a decade ago. Since Brexit, all have Irish passports. Is she supportive of Scottish independence? “Oh, I’m not going there,” she says, laughing. How did she feel about turning 50 in May? “Hand on heart, it didn’t bother me. Because what’s the alternative? Not getting older?”

The Marriage Portrait is out now from Knopf

Patricia Nicol is a freelance journalist and a columnist for The Sunday Times and the Daily Mail