In the summer of 2004, Paula Rego wrote to Martin McDonagh asking for permission to name some pictures after his play The Pillowman. His shocking investigation into the relationship between art and life featured two brothers under interrogation for the torture and murder of children. One is a writer whose stories are summarised by an investigator as: “A hundred and one ways to skewer a fucking five-year-old.”

Rego, then a 69-year-old grandmother as well as a world famous artist, had been taken to see the play at the National Theatre in London by one of her daughters, who knew it would resonate with her. “The brutality and beauty and humour rang very true and like something I had known all my life,” she wrote to McDonagh. “I am actually Portuguese, although I have lived in London for 50 years, and our stories are brusque and cruel like yours.”

‘She was drawn to the idea that your foibles could feed off you like parasites’

The Pillowman is set in a totalitarian state in which people’s imagination is ruthlessly policed. When Rego was growing up, Portugal was under the dictatorship of António de Oliveira Salazar, who controlled a deeply conservative society for more than three decades with the help of his secret police. Her identification with the play was so strong that she had gone so far as to make her own “pillowman”, a life-size doll made of cushions stuffed into old tights, as the model for the central panel of a triptych that was to be exhibited at Tate Britain that autumn.

Cushions stuffed into tights … the life-size Pillowman that Rego made in the studio that is now her archive. Photograph: Nick Willing/© Estate of Paula Rego. Courtesy Ostrich Arts Ltd and Cristea Roberts Gallery

So began an excitable, almost childlike correspondence that culminated in McDonagh ransacking his bottom drawer for more stories she could use, while floating the idea of a more formal collaboration on a picture book in the future. “Finally,” he wrote in February 2005, “I’m sending you some stories. Now listen, they were written quite a few years ago and some are very young and silly and none of them are well written. But some of them have interesting images, maybe, so if anything takes your fancy let me know.” He wouldn’t be able to do anything for a while, he added, because he was off to New York to restage The Pillowman on Broadway.

Rego’s pillowman, his bulgy hippopotamus head flopping on his chest above white wellington boots, still lounges on a grubby sofa in the north London studio that has become her archive since her death in 2022. Under the spell of a place where so much great work was made, it feels as if he’s keeping watch while the artworks inspired by McDonagh’s stories are bundled up for exhibition at London’s Cristea Roberts Gallery.

The show focuses on a three-year period of Rego’s output, from 2005 to 2007, when she developed a practice of drawing and painting from scenarios that she assembled in her studio with the help of her assistant, Lila Nunes, who also posed for many of them. Though Rego didn’t consider these constructions to be art in their own right, neither did she discard them when their work was done. Some of the puppets involved, which she called bonecos – the Portuguese word for dolls – will be on display for the first time.

Disturbing … Adam Godley and David Tennant in The Pillowman. Photograph: Donald Cooper/Alamy

At the heart of this output was the “McDonagh series”, based on the stories that McDonagh himself explains were written in his 20s, more as the outlines of a potential short film series than as publishable pieces of work. The only time they had previously seen the light of day was when he showed a few of them to the Pillowman cast as examples of the sorts of stories under investigation in the play.

The imaginative connection between the mature artist and the young playwright and film-maker – whose work has since gone on to sweep up awards on both sides of the Atlantic – is startlingly powerful, and ranges from a typewriting monkey to a man with turtles for hands. It doesn’t follow straight lines. But of the four stories that Rego chose from the dozens she was sent, one in particular drove straight to the heart of one of her own enduring obsessions.

The story involved a forest full of babies calling piteously out to the conscience of the mother who had aborted them. “It is a very perverse story, against what I stand for, so I don’t know why I did it,” she wrote at the time. There is no forest in the paintings she made in response. In one, a woman is slumped in a bathroom with fancy floral wallpaper, a foetus in her lap. In another, a young mother cradling a baby sits on a toilet with the bloody remnants of an abortion in a bowl at her feet.

‘I’m sending you some stories. Some are very silly and none of them are well written’ … Martin McDonagh. Photograph: Antonio Olmos/The Guardian

As an art student at London’s Slade in the early 1950s, Rego had several backstreet abortions herself, before returning to her family home in Portugal to give birth to her first daughter, in a society hellbent on outlawing young women like her. She felt no guilt, she recalled; merely anger about the unnecessary pain, misery and danger inflicted. It was a subject to which she would return time and again, in artworks that would play a part in galvanising the Portuguese people to overthrow their country’s ban on abortion.

In a film, Secrets & Stories, made by her son Nick Willing towards the end of her life, Rego talked about her outrage after the decriminalisation of abortion was rejected in a 1998 referendum. When a second referendum was scheduled for 2007, she printed up eight etchings for distribution to the national and local press. The Portuguese president at the time, Jorge Sampaio, is among those who testify in the film to the works’ role in changing public opinion.

Although Rego rarely made appearances in her own paintings, the autobiographical content is there for those who know what to look for, according to Willing – whose responsibilities for his mother’s legacy include caring for an archive of several thousand works, overseeing 23 exhibitions around the world this year, and looking after a museum, the Casa das Histórias Paula Rego, which was founded in 2009 near her old family home.

Personal traumas … Rego in her London studio in 2004. Photograph: Independent/Alamy

For all its apparent grotesquery, Pillowman personifies Rego’s affection for her industrialist father, who brought his family up on a quinta – country estate – on the Portuguese riviera, where their neighbours included celebrities and royalty. The triptych contains references to Saint-Exupéry’s Little Prince, and to the exiled king of Italy, who was known to pick up young male sex workers on the beach.

After her father’s death, the family’s electronics business went bust and the quinta had to be sold – a traumatic series of events that is dramatised in another picture from the McDonagh series. The story it is based on tells of a piglet’s futile prayers to be saved from slaughter by a scarecrow it had earlier rescued from a wildfire. Rego represents the scarecrow as a crucified woman with a cow’s skull, who towers above a decapitated pig’s head, next to a sleeping girl. In the background the sky is burning. As a child, says Willing, Rego was traumatised by the slaughter of a pig she had come to love. The sleeping girl represents her guilt at allowing her whole inheritance to go up in flames, although the fault wasn’t in fact hers but her husband’s. Victor Willing, who had been a star student at the Slade when they met, disastrously thought he could run the family business himself. Its failure forced Rego to beg for grants to keep their young family afloat.

Mysterious works … Rego’s Camouflaged Hands, 2006. Photograph: © Estate of Paula Rego. Courtesy Ostrich Arts Ltd and Cristea Roberts Gallery

The most mysterious picture to emerge from the McDonagh collaboration is the one with a man who has turtles in place of hands. Willing is reluctant to overexplain it, because Rego never explained it to him. But he believes it has something to do with the lifelong depression from which she suffered, as her beloved father had before her. “I think she was very drawn to the idea that the things that weigh you down – like depression or all your foibles and idiosyncrasies – they’re part of you, but they’re also living creatures that feed off you, like parasites. They are a curse but also a privilege and, in getting rid of them, you perish,” he says.

The three years on which the exhibition focuses were among the most productive of Rego’s life, says Willing, resulting in an enormous number of pastels and prints. “She had a particularly purple patch with the Martin McDonagh stories, and he gets a lot of credit for exciting in my mother perhaps her most accomplished work.”

The picture book sadly never materialised. “It would’ve been a dream, though I think that dream was mostly in my head,” says McDonagh. “But to be a tiny part of the art of one of the greatest artists of the 20th century is mind-blowing to me. I still can’t really believe it.”

Paula Rego: Drawing from Life is at Cristea Roberts Gallery, London, from 27 November to 17 January. Paula Rego: Story Line will be on view at Victoria Miro, London, from February to March.