The director of Oscar-nominated Green Book has said “our hearts were in the right place” while making the controversial film.

Based on a true story, the movie stars Mahershala Ali as jazz musician Don Shirley and Viggo Mortensen as the no-nonsense bodyguard assigned to drive him through the segregated Deep South of the 1960s.

It has attracted controversy amid claims by Shirley’s family that they were not consulted, while some critics condemned it as another “white savour” Hollywood movie.

Mahershala Ali
Mahershala Ali has won critical acclaim for his role in Green Book (Ian West/PA)

However, director Peter Farrelly defended the film and said it was made with good intentions.

He told the Press Association: “It’s a movie for everybody. I know a lot of people have different opinions about it and I like that it’s getting people talking about race because that’s what the movie is supposed to do.

“Our hearts were in the right place when we made this movie.”

Despite the controversy, Green Book has been a critical hit, earning five Oscar nominations including best picture and acting nods for Mortensen and Ali.

Farrelly, who also directed Dumb And Dumber and There’s Something About Mary, has personally been mired in controversy since Green Book’s release.

Viggo Mortensen
Viggo Mortensen has earned an Oscar nomination for his role in Green Book (Jonathan Brady/PA)

He apologised after admitting exposing himself on set during the 1990s as part of a vulgar practical joke.

The film’s co-writer, Nick Vallelonga, deleted his Twitter account after a 2015 tweet resurfaced in which he supported the false claim that Muslims in New Jersey celebrated the 9/11 terror attacks.

Ali is a Muslim.

Actor Joseph Cortese, who appears in Green Book, said “anybody who has half a brain” can “read between the lines” over the controversy surrounding the film.

He told the Press Association: “It’s vicious, it’s uncalled for, it’s people who are envious of this movie.

“Nobody expected this to come out how it did. To come after someone for something they did 20 years ago, or five years ago – we’ve all got skeletons in our closet.

“I just don’t choose to be like that, I’m about love.”