When he last appeared on screen as a Scot, he famously overcame Edward Longshanks to win the Battle of Stirling Bridge as William Wallace in Braveheart.

But Mel Gibson's latest portrayal of a Scottish hero has ended in resounding defeat after losing a legal battle to stop the release of his latest film.

The Australian stars as Sir James Murray, the Scot who created the Oxford English Dictionary with the help of a convicted killer, in the Professor and the Madman.

Filming took place in Dublin in 2016 but a huge row broke out after production company Voltage started showing a cut of the movie which the Oscar-winning star was unhappy with. 

He wanted extra scenes to be shot at Oxford University, where much of the story of the film actually took place, but claims they refused.

In a lawsuit filed in Los Angeles, Gibson, 62, alleged that Voltage has violated its agreement, which gives him approval of the final cut of the £20 million film.

However, following a court hearing Judge Ruth Kwan refused a request to hand the film rights over to Gibson and ruled Voltage were not in breach of contract.

She said: “Plaintiff did not submit admissible evidence showing the existence of an actual controversy with Defendants."

The film tells the story of James Murray, from Denholm, near Hawick in Roxburghshire, who left school at 14 because his parents could not afford fees.

He became a teacher at Hawick Grammar School aged 17 and three years later was headmaster.

In 1878, he was invited to Oxford to meet the delegates of the Oxford University Press, with a view to his editing a new English dictionary.

As he Murray embarked on the task, he formed a relationship with Dr William Chester Minor who was incarcerated in Broadmoor after being diagnosed with insanity when he killed a man. 

Minor, played by Sean Penn, was a former Union Army captain and surgeon in the American Civil War.

Winchester believes he lost his mind after being forced to use a red-hot iron to brand the face of a deserter with the letter D.

He was confined to a US asylum for a while before moving to London, where his paranoid delusions led to murder.

His victim, who he falsely believed had broken into his room, was a father of six whose wife was pregnant when he died.

Minor was found not guilty of murder by reason of insanity and locked up in Broadmoor.

As he had his army pension and was not judged dangerous, he was able to buy and read books and became one of Professor Murray's most prolific volunteers.

He read hundreds of books during his time in Broadmoor and sent Professor Murray thousands of examples of the meaning of words after seeing them written down in context.

His work proved invaluable to Professor Murray's efforts to compile the definition of every English word. 

Professor Murray later successfully campaigned to have him returned to the US and then Home Secretary Winston Churchill agreed to his deportation. He died in a Connecticut asylum for the elderly insane in 1920.

The film is based on Simon Winchester's book and revolves around Professor Murray first discovering that Minor was a convicted killer.

But it has been marred by various disputes with director Farhad Safinia cliaming he was thrown off the project, and is suing for copyright infringement and defamation. He had also asked for the current version of the film to be destroyed.

However Voltage chief executive Nicolas Chartier hit back saying Gibson and Safinia had originally agreed to shoot the Oxford scenes — which involved 200 extras — at the Library of Trinity College in Ireland, but changed their minds at the last minute.

He claimed: "These issues caused the production to extend two days past the schedule of 40 shooting days and caused additional costs to the production, which was over budget by approximately $1.3 million.

“Mr Gibson claims to have final cut while refusing to watch the picture, work on the picture, or edit it."

Gibson's lawsuit, filed by attorney Jeffrey McFarland, stated: "The agreements require that things such as material changes to the screenplay, change of director from Mr Safinia to someone else, the final production budget and schedule, and selection of filming locations be agreed to by Icon and Mr Gibson.

"Further, as extra insurance that his vision of the film was protected, Mr Gibson has the right, if necessary, to select the final cut of the film that is released between a cut prepared by Mr Safinia and a cut prepared by Voltage."

Winchester, who lives in Massachusetts, has praised Gibson's Scots accent in the film which was panned for his role as William Wallace in 1995.

He added: "It's so long since I saw Braveheart. I think it was the action and not the accent that gripped me in that film. But I think Scots will approve of Gibson's Scottish dialect."