Image copyright Alan Amato Image caption Adam Driver stars in The Man Who Killed Don Quixote

Terry Gilliam's Don Quixote film will screen at the Cannes Film Festival as planned, a court in Paris has ruled.

The decision follows an attempt by one of the production's former backers to have the gala premiere shelved.

Festival boss Thierry Fremaux took to the stage in one of Cannes' cinemas on Wednesday to announce the ruling.

It follows reports that the Monty Python star had been treated in hospital and that his film had lost its US distributor.

"The request of Paulo Branco for a ban was rejected by the courts," the festival declared on its official Twitter feed.

"The Man Who Kill[ed] Don Quixote will be screened at the close of the 71st Festival de Cannes! And Terry Gilliam will be there."

The festival also posted a message and a picture from Gilliam, in which he said he was "not dead yet" and was "coming to Cannes".

Portuguese producer Branco, who claims he owns the rights to the film, had attempted to stop the screening.

At a hastily assembled press conference in Cannes, Branco said it had been "very wise" of the judge to grant the festival an "exceptional authorisation" to show the film.

"The decision doesn't interfere with any other decisions that have already been taken that give us the rights [to the film]," he continued.

The legal tussle around Don Quixote's Cannes debut is the latest chapter in an extraordinarily protracted journey to the screen.

A previous attempt to make the film with Johnny Depp collapsed in 2000, spawning a feature-length documentary, Lost in La Mancha, in the process.

Gilliam pressed on and finally managed to complete the film, with Jonathan Pryce and Adam Driver playing modern versions of Cervantes' Don Quixote and Sancho Panza characters.

The film sees Driver play a film-maker who returns to the Spanish town where he made a student film about Quixote to find it much-changed as a result.

More from Cannes:

Gilliam was said to have had "a mild alert" regarding his health that led to an overnight stay in hospital. Riviera newspaper Nice Matin reported that he had suffered a minor stroke, but the festival's tweet has been the only official update.

A statement sent to Deadline before the court ruling said Gilliam was "currently at home preparing for his trip to Cannes".

It was also reported on Wednesday that Amazon was set to pull out of distributing the film in the US.

The Man Who Killed Don Quixote will screen on 19 May after the festival's closing night ceremony.

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