Image copyright Getty Images/reuters Image caption Dame Judi said Spacey "is, and was, a most wonderful actor"

Dame Judi Dench has said it was wrong to remove her "good friend" Kevin Spacey's performance in a recent film.

"I can't approve, in any way, of the fact - whatever he has done - that you then start to cut him out of films," she said at a film festival in Spain.

She said Spacey was "an inestimable comfort" when they worked on a film shortly after her husband's death.

A number of allegations of sexual misconduct have been made against the Oscar-winning actor, which he denies.

The scandal prompted Sir Ridley Scott to excise his performance as oil tycoon Jean Paul Getty from All the Money in the World and reshoot his scenes with Christopher Plummer.

Plummer went on to be nominated for an Oscar, a Bafta and a Golden Globe for his contribution to the film.

Image copyright Getty Images/Miramax Image caption The actress appeared with Spacey in 2001 film The Shipping News

Speaking at the San Sebastian Film Festival on Tuesday, Dame Judi suggested that the decision to erase Spacey's appearance set a troubling precedent.

"Are we to go back throughout history now and anyone who has misbehaved in any way, or has broken the law, or has committed some kind of offence, are they always going to be cut out?" she told reporters.

"Are we going to exclude them from our history? I don't know about any of the conditions of it, but nevertheless I think he is, and was, a most wonderful actor... and a good friend."

The 83-year-old said she "couldn't imagine" what Spacey - with whom she worked on 2001 film The Shipping News - was doing now.

A spokeswoman for the actor said last November that he was "taking the time necessary to seek evaluation and treatment."

Image copyright Reuters Image caption Dame Judi received a lifetime achievement award in San Sebastian on Tuesday

Following the allegations made against him, the actor was written out of the final series of Netflix drama House of Cards.

Billionaire Boys Club, a film in which he had a supporting role, performed poorly at the US box office when it was released in July.

Dame Judi's comments about her former co-star have drawn a mixture of censure and praise on social media.

Jean-Pierre Leduc praised her for "speaking her mind" and that people "should be given second chances".

Other Twitter users, though, said she had "crossed a line" and that her support for Spacey was "sickening".

Dame Judi travelled to Spain this week to promote her new film, espionage thriller Red Joan, and receive a lifetime achievement award.

The Oscar, Bafta and Olivier winning actress described herself "a jobbing actor", adding: "I can't bear to turn a part down because I think I might not be asked again."

Follow us on Facebook, on Twitter @BBCNewsEnts, or on Instagram at bbcnewsents. If you have a story suggestion email entertainment.news@bbc.co.uk.