Media playback is unsupported on your device Media caption The moment La La Land's producers realised Moonlight had won best picture

With the wrong film being mistakenly named best picture at the Oscars - La La Land instead of Moonlight - lots of people are asking how this could have happened.

Two envelopes for each category

Two people count the votes and know the winners in advance. Each has a full set of envelopes containing cards with the winners' names - just in case something happens to the other set.

Those people - from accountancy firm PwC - stand on either side of the Oscars stage and hand the envelopes to the award presenters just before they step on stage.

So after Emma Stone won best actress, the other best actress envelope was handed to Warren Beatty - who was presenting the best picture prize - by mistake.

That explains why a confused Stone told reporters afterwards: "I was holding my best actress in a leading role card that entire time."

Image copyright PwC Image caption Martha Ruiz and Brian Cullinan from Price Waterhouse Coopers (PwC) are the only two people who know the results in advance

Image copyright Getty Images Image caption Faye Dunaway and Warren Beatty with the red envelope at the centre of the confusion

Warren Beatty hesitates

It looked like the veteran actor was fooling around when he opened the envelope, looked at the card, then looked inside the envelope again to see if there was another card inside.

He checked again, then showed the envelope to his co-presenter Faye Dunaway. She read the words: "La La Land."

Beatty explained: "I want to tell you what happened. I opened the envelope, and it said Emma Stone, La La Land. That's why I took such a long look at Faye, and at you [the audience], I wasn't trying to be funny."

Oscars host Jimmy Kimmel said afterwards: "He was confused because the card, which he showed to me by the way, said 'Emma Stone, La La Land' on it.

"So this was confusing obviously, we thought he was being coy and cute to make everybody suffer but in reality he was perplexed by why her name was on it."

Image copyright AP Image caption La La Land's Jordan Horowitz gives his acceptance speech - unaware a mistake has been made

Image copyright Reuters Image caption Realisation dawns on the faces of the La La Land cast and crew as an official takes to the stage

Image copyright AP Image caption Moonlight's Mahershala Ali hugs Emma Stone, who won best actress for La La Land, as her co-star Ryan Gosling looks on, bemused

The mistake is rectified

With the La La Land acceptance speeches in full flow, the PwC people and other officials came on stage to inform the film's cast and creators - and the world - that there had been a terrible mistake.

La La Land producer Fred Berger said: "We lost by the way, but you know."

Fellow producer Jordan Horowitz then said: "Guys, I'm sorry, no, there's a mistake. Moonlight, you guys won best picture."

And the third producer Marc Platt said: "This is not a joke I'm afraid they read the wrong thing."

Horowitz added: "This is not a joke, Moonlight has won best picture." He then held the card up to the audience to prove his point, reading from it: "Moonlight, best picture."

Cue bedlam.

Image copyright Reuters Image caption Warren Beatty tries to explain what happened as the team behind Moonlight take in the news

Image copyright Reuters Image caption The confusion turns to celebration as Moonlight's win sinks in

Oscars 2017: Full coverage

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