“I've never been a big fan of biopics, I just don't like the form,” says two-time Oscar-winner Jodie Foster about her choice of roles. “I prefer making dramatic films about ideas, and being able to shape the character I play.”

Her new movie, however, is an exception to this rule: The Mauritanian is based on real-life events and characters. Directed by Kevin Macdonald, it tells the true story of Mohamedou Ould Slahi, a terror suspect held for 14 years in Guantánamo Bay without charge. Foster plays Nancy Hollander, the American defence lawyer determined to defend his rights, while Tahar Rahim (A Prophet) plays Slahi.

The 58-year-old actress points out that in a career spanning half a century she has played only one other true-life figure, in 1999’s Anna and the King, in which she played schoolteacher Anna Leonowens (whose story had been told in the 1956 musical The King and I). But the Slahi case was “so interesting, and its extraordinary story so nicely crafted, like a real dramatic film, that I was totally drawn to it”, she says. “The movie opened up a world that I didn’t know much about.”

Other factors also compelled her to take the role. “First of all, there was Kevin Macdonald [maker of The Last King of Scotland] . . . I thought he would be the right director to do it like a documentary, and bring to it his customary non-judgmental approach,” she says. And when she heard that Benedict Cumberbatch was already aboard, playing military prosecutor Stuart Couch, “it made my decision pretty easy.”

There was room for artistic licence in Foster’s performance. “Nancy Hollander is actually a lovely person, soft-spoken and warm, whereas my Nancy is meaner, not very polite, and wary . . . I thought it was important to create a character that exaggerates certain parts of her and subdues other parts.”

Hollander, Foster says, “really wants people to know this Muslim man, who has been portrayed as a figure of terrorism, to see him as a real guy who is affectionate and flawed. He still has so much humanity, the ability to forgive his captors.”

Slahi’s story is one of hope but it is also a sobering reminder of the human cost of the war on terror. “This film has a lot to do with 9/11, and the fear and terror that inspired the government's reaction,” Foster says. “They decided to stop a second terror attack, to get Arabs off the street by any methods, even if that meant incarcerating innocent people. But they did it knowing that it was illegal, that it didn’t live up to the US Constitution or the Geneva Conventions.”

She believes the movie is particularly relevant to those who have grown up in the decades since 9/11, which includes her two sons (Kit, 19, and Charles, 22). “It's an opportunity for us to revisit dark parts of our history,” Foster says. “The story shows what happens when you throw out the rule of law, the constitution, the basic elements of democracy, in order to pursue revenge.”

Foster began her career as a child actress, playing an underage prostitute in Martin Scorsese’s 1976 Taxi Driver: the performance earned Foster her first Oscar nomination at the age of 13. Since then, she has excelled in several iconic films, including The Accused (1988), for which she received her first Best Actress Oscar, and The Silence of the Lambs, which swept the 1992 Academy Awards, including a second Best Actress prize for Foster. Last week, both she and Rahim were nominated for Golden Globes for The Mauritanian.

Over the years, Foster has learnt how to separate her professional from her domestic life, she says. “It’s a skill I’ve adopted. To be fully committed to a role, you have to be obsessed, so I bring my obsession home, but I don't bring my character home.”

But making The Mauritanian brought back memories from September 2001 that were both painful and joyous. “I was pregnant at the time, I was on bed rest, and I was due to have the baby in a matter of days,” Foster says. “It was a very particular moment in my personal life.”

The film represents an opportunity to reflect on the almost 20 years since the attacks. “It deals, perhaps obliquely, with the residual effect of what 9/11 meant to Americans and what it made us become. It’s a way to process this weird transformation of our country, when we went from being innocent about our effect abroad to this tragic moment that would lead to the war on terror, a political war we waged against whoever we determined was going to threaten us.”

It was Slahi’s story that convinced Foster that these issues could be tackled through film. “I don’t love political movies unless they make a strong emotional connection, and this film is in that arena,” she says.

Slahi wrote five books while locked up, including his best-selling memoir Guantánamo Diary, released in 2015, on which the film is based. “Our movie is a testament to him and to his faith,” Foster says. “When you’re in a situation like this, faith is what keeps you from devolving into the worst of yourself. He became the best of himself. For all the tragedy he faced, his sense of humour is remarkable, and that allowed him to transform out of his terrible circumstances.”

Foster and Slahi spoke via Skype and Zoom but she didn’t meet him in person until he visited the set. “We didn’t think he was going to be able to come to South Africa, where we shot, because [the Mauritanian government] retained his passport. He wasn’t even able to go to Germany to visit his newborn son for almost two years.”

Then, as in the movie, there was a sudden change of fortune. “By some miracle, the South African government was like: ‘OK, we’ll get you a visa.’ He just showed up. Nancy [Hollander] was able to be there, and they were like an old married couple.”

For Foster, Hollander is a hero. “In 2010, she wrote a piece for the New York Times in which she spelt out why she saw it as her duty to defend individuals accused of terrorism. She faced some harsh criticism for helping inmates like Mohamedou preserve their rights.”

As for her estimable co-star, Foster says: “When people ask me what I love about making movies, it’s sitting in a room with a guy like Tahar and supporting someone who’s giving the performance of his life.”

It was a hard shoot for everybody, but especially for Rahim, a Frenchman of Algerian descent and a father of two. “He would finish a scene and jump on a plane [to France] and spend several days with his baby, and then he had to lose 15 pounds and come back and shoot torture scenes.”

Foster says she has reached a point in her career where “the only point of acting now is telling stories with meaning. I’ve been doing it for a very long time, and I’m picky about what I choose to spend my time on, because I’m older and there are other things in life I want to be doing. As powerful as the art form is, I only want to do it when it feels meaningful.”

For her, The Mauritanian is one such story and it is unusual for an American movie in at least one particular way. “It is rare in treating a Muslim in humanised ways,” she says. “You fall in love with him as a protagonist, and for me, that’s reason enough to make the movie. It’s satisfying to feel we’re making the world better rather than worse by sharing these stories.”

‘The Mauritanian’ is released in the US on February 12 and in the UK on April 1

Follow on Twitter to find out about our latest stories first

Listen to our podcast Culture Call, where FT editors and special guests discuss life and art in the time of coronavirus. Subscribe on Apple, Spotify, or wherever you listen