Two women are chatting in front of a painting of Catherine of Alexandria, a saint martyred in the fourth century. The figure is shown leaning on a wheel studded with iron spikes, part of the instrument of her torture. “She’s my friend now,” says one of the women. “Strong lady,” says the other. “Like the girls where I’m from.” They move on to the subject of Catherine’s fate. “These martyrs aren’t martyrs like you and me,” says one. “I’m not dying for no cause,” adds her friend.

The women, who cannot be named, are inmates at HMP Send, a prison for high-risk female offenders in Surrey. The painting, by a woman who suffered appalling abuse and violence in 17th-century Italy, is hanging in the jail library. It was bought by the National Gallery for £3.6m last year and, as part of a tour of unlikely venues that has so far included a doctor’s surgery and a school, the gallery has sent it here.

It is the first loan of a painting to a prison by any British national collection. When I ask Carlene Dixon, the prison’s governor, if she had concerns about the emotions this intimate artwork might stir in the prisoners, she jokes: “I was more worried about somebody nicking it.”

The work is by Artemisia Gentileschi, who broke through the heavy black marble ceiling of baroque Italy to become a successful female painter. Raped as a teenager, the artist fused the trauma of her life with biblical scenes, in this case painting herself as the martyred saint. The artist is often regarded as more savage than Caravaggio, exacting revenge in blood-splattered works. In another magnificent painting, called Judith Beheading Holofernes, we see a muscular woman holding the general down on a bed while another saws his head off. He’s awake.

Saint Catherine was sentenced to be ground to death between spiked wheels but the machine was broken thanks to what was seen as divine intervention and she survived. That’s the moment of triumph with which Gentileschi identifies. What does this portrayal of faith, endurance and redemption look like to someone who’s locked up? “They were just firing questions at me,” says Jo Lewis, an artist who led workshops with the prisoners. “They wanted to know all about Artemisia and her time.”

But the painting spoke to them just as strongly as the details of the artist’s life. Prisoners saw their own longings in there. To some, the wheel looked like a lid, leading to speculation that Catherine had just escaped from something – possibly a container or a cell. It’s a strikingly personal interpretation and gives rise to a powerful connection that spans centuries: like Gentileschi, they see something of their own lives mirrored in what Catherine went through.

HMP Send is a formidable place, hidden away in a quiet Surrey suburb. I pass through one gated section after another. By the time I’ve crossed the grounds and made it to the library, I feel trapped. For many prisoners, this is a long-term home. “About 40% are serving at least 10 years,” says Dixon. “And many are serving life.”

Gripping … inmates’ drawings of Gentileschi’s self-portrait. Photograph: Christian Sinibaldi/The Guardian

None of the prisoners knew that a £3.6m painting was coming. Instead of an announcement, which might have jeopardised security, prisoners were simply invited to sign up for workshops. Those who did so were rewarded with a face-to-face encounter with a baroque masterpiece. Intense discussion ensued, particularly on the subject of the wheel. “We talked about it as something that takes you somewhere else,” says Lewis.

The pop-up tour is part of the buildup to the National Gallery’s big Gentileschi show next year. She could well be the ideal artist to take to a women’s prison. Lewis told the inmates about the artist’s rape at 17 and the subsequent trial – at which she, and not her attacker, was tortured. “Seventy-two per cent of women in custody have suffered some form of abuse,” says Dixon. The inmates’ identification with Artemisia is evident in their own gripping drawings of the portrait: they look more like acts of self-expression than careful copies.

Some prisoners here are accomplished artists who have taken part in workshops with nearby Watts Gallery. HMP Send has started an annual exhibition at which locals can – and do – buy prisoners’ work. “Making art,” one prisoner tells me, “contrasts with the doom and gloom of being here.”

The inmates return to discussing Gentileschi’s infinitely absorbing painting.

“Her strength of character is there in her forearms.”

“I think she was just fat.”

“There is a little bit of pain in her eyes.”

“She’s saying, ‘I’ve survived.’”

• The National Gallery’s Artemisia Visits can be next seen at the E17 Art Trail, London, and will run throughout 2019.