Moonlight has won best picture at the Oscars – but only after Faye Dunaway initially announced La La Land had won.

Dunaway’s co-presenter Warren Beatty said “Emma Stone, La La Land” had been written in the envelope he was given.

The team from La La Land were in the middle of their acceptance speeches when the mistake was discovered.

Moonlight director Barry Jenkins said: “I don’t think my life could be changed any more dramatically than it has in the last 20 or 30 minutes.”

His coming-of-age film about a young gay black man also won adapted screenplay and best supporting actor.

“And I have to say, and it is true, it’s not fake, we’ve been on the road with these guys (from La La Land) for so long and that was so gracious, so generous of them, my love to La La Land, my love to everybody, man.”

La La Land won six Oscars including best actress for Emma Stone. Damien Chazelle, director of La La Land, became the youngest filmmaker to win a best director Oscar, at the age of 32.

Stone, who won the coveted best actress prize, said backstage: “I’m so excited for Moonlight. Of course it was an amazing thing to hear La La Land and I would love to win best picture. But we are so excited for Moonlight. I think it is one of the best films of all time.

“Is that the craziest Oscar moment of all time? Cool! It’s going to be history.”

Host Jimmy Kimmel said after the show that Beatty had been given the wrong envelope.

Bonnie and Clyde stars Beatty and Dunaway announced La La Land had taken the best picture prize – but then the musical’s producer Jordan Horowitz announced there had been a mistake.

He said: “This is not a joke. Moonlight is best picture,” and showed the camera the card that revealed the winner.

Two La La Land producers had already given their acceptance speeches before the mistake was revealed.

Host Jimmy Kimmel joked that he knew he would he would mess up compering the ceremony, and added: “Personally I blame Steve Harvey for this,” referring to Harvey’s mistake in announcing the Miss Universe winner in 2015.

‘In my dreams’

Beatty had opened the envelope but hesitated to read out what it said inside, leaving it to Dunaway to announce La La Land.

He returned to the microphone to say: “I want to tell you what happened. I opened the envelope and it said ‘Emma Stone, La La Land’, and that is why I took such a long look at Faye and at you.

“I wasn’t trying to be funny. This is Moonlight for best picture.”

The film’s director Jenkins said: “Very clearly even in my dreams this can’t be true. But to hell with it because this is true. It’s true, its not fake.”

Paying tribute to the team behind La La Land for the way they handled the mistake, he said: “We have been on the road with these guys and it was so gracious and so generous of them.”

La La Land also picked up best cinematography, best score and best original song for City of Stars.

It also won best production design.

Casey Affleck won best actor for Manchester by the Sea, while the drama also won best original screenplay.

Mahershala Ali won best supporting actor, for Moonlight.

He thanked his wife in his acceptance speech, telling the audience she gave birth to their daughter four days ago. It also picked up best original screenplay.

In the press room, Ali explained: “When they said ‘Moonlight you guys have won’, it just threw me a bit – more than a bit – because I didn’t want to go up there and take something from somebody. And It’s very hard to take joy from a moment like that. But I feel very fortunate for all of us to walk away with best picture.

‘Celebrating living a life’

Best supporting actress went to Viola Davis for Fences, directed by and starring Denzel Washington.

The film is an adaptation of August Wilson’s play of the same name.

“There’s one place that all the people with the greatest potential are gathered – and that’s the graveyard,” she said as she collected her award.

“We are the only artists who celebrates what it means to live a life. Here’s to August Wilson who exhumed and exhalted the ordinary people.”

Davis, who had been nominated twice previously for Doubt and The Help, also thanked her “captain”, Washington.

Host Jimmy Kimmel put on a strong performance, with much of his patter unsurprisingly relating to the current US political climate.

In a reference to Donald Trump’s Twitter attack on Meryl Streep following her criticism of him at the Golden Globes, Kimmel joked that Streep was “uninspiring… mediocre… underwhelming and lacklustre”.

He asked the audience to give a round of applause for “the highly overrated Meryl Streep. Great dress, is that Ivanka?”

Kimmel also joked that Hollywood doesn’t discriminate – apart from “on age and weight”.

The first political speech of the night came from Alessandro Bertolazzi, one of the make-up and hairstyling winners for Suicide Squad, who said: “I’m an immigrant, I’m from Italy, this is for all the immigrants.”

Other winners included Colleen Atwood, who won an impressive fourth Oscar for costume design for Fantastic Beasts and Where to Find Them.

Kevin O’Connell finally picked up an Oscar after 21 nominations for Hacksaw Ridge. He was first nominated back in 1984 for Terms of Endearment.

The film also picked up best editing.

Iranian film director Asghar Farhadi’s The Salesman was named best foreign film.

Farhadi chose to stay away from Sunday’s ceremony following President Trump’s attempt to ban travel from Iran and six other mainly Muslim countries.

Zootopia won best animation, beating films such as Kubo and the Two Strings and Moana.

Other winners included British film The White Helmets, which picked up best documentary short.

The US denied entry to 21-year-old Syrian Khaled Khatib behind the film because of problems with his documents.

The a 40-minute Netflix documentary follows volunteers who risk their lives to rescue civilians in Syria.