PricewaterhouseCoopers, the accounting firm that tallies the Oscars voting, later apologized, saying in a statement that the presenters were erroneously given the wrong envelope.
Here is the full breakdown of the dramatic best picture mix-up.
9:03 p.m. Pacific time
Presenters Faye Dunaway and Warren Beatty take the stage to announce the best picture nominees.
Beatty opens the envelope, takes out the card and appears to look inside the envelope for another card.
He smiles, pauses and says, "And the Academy Award ..." then pauses again. He looks back down at the card before saying, "For best picture ..."
"You're impossible. Come on!" Dunaway says, and Beatty passes the card to her.
She glances at the card and announces, "La La Land"!
After the "La La Land" team members embrace, they head to the stage to accept the biggest award of the night.
"Moonlight" director Barry Jenkins later told reporters backstage, "I think all the movies that were nominated were worthy, so I accepted the results. I applauded like everyone else."
"I noticed the commotion that was happening, and I thought something strange had occurred," he said.
"La La Land" producer Jordan Horowitz, holding the Oscar and the envelope onstage, begins his acceptance speech.
Behind Horowitz, people begin to realize something is amiss when an Oscars producer walks onstage.
As "La La Land" producer Fred Berger gives his acceptance speech, people hover behind him, and "La La Land" star Emma Stone, who won the best actress award minutes before, is seen mouthing, "Oh, my God."
Berger concludes his acceptance speech, turns to the people behind him and then turns back to the mic, saying, "We lost, by the way."
Horowitz steps to the microphone and says, "Guys, I'm sorry. No, there's a mistake. 'Moonlight,' you guys won best picture ... This is not a joke."
"This is not a joke," "La La Land" producer Marc Platt echoes. "I'm afraid they read the wrong thing."
"This is not a joke," Horowitz repeats. "'Moonlight' has won best picture."
Backstage there was an audible collective gasp, then silence.
Horowitz holds up the best picture card reading "Moonlight" and shows the audience. He announces "'Moonlight,' best picture," and the crowd erupts.
"There was a lot of confusion onstage, and at a certain point it was clear that the wrong envelope had been given," Horowitz told "GMA" exclusively this morning. "Then they kind of showed us the best picture envelope, and it said 'Moonlight,' and that's when I sort of jumped to the mic and made sure everybody knew what was going on."
He added, "It was like this slow, steady realization that something wasn't right. It needed to be corrected, so we jumped in and did it."
Horowitz said he held up the card because "I think people needed clarity at that moment."
"I would like to see you get an Oscar anyway," Kimmel says to Horowitz.
"I'm going to be really proud to hand this to my friends from 'Moonlight,'" Horowitz says.
Then it was time for Beatty to take the mic.
"Warren, what did you do?" jokes Kimmel.
"I want to tell you what happened," Beatty says to the audience.
"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. I wasn't trying to be funny," Beatty says.
"Well, you were funny," says Kimmel.
As Beatty speaks, Horowitz is seen in the background embracing "Moonlight" supporting actor winner Mahershala Ali and others from the "Moonlight" team. Horowitz then hands off the Oscar.
"This is 'Moonlight,' the best picture," Beatty says, and the audience erupts in applause.
Matt Damon whistles.
Jenkins says to the crowd, "Even in my dreams, this could not be true. But to hell with dreams. I'm done with it, because this is true. Oh, my goodness."
"Moonlight" producer Adele Romanski says, "I'm still not sure this is real, but thank you to the academy, and it is so humbling to be standing up here."
Jenkins later told reporters that Beatty refused to show anyone else the winning card before showing it to him.
"He came upstairs, and he walked over to me, and he showed the card. Everybody was asking, 'Can I see the card?' And he's like, 'No, Barry Jenkins has to see the card. I need him to know,'" Jenkins recalled. "And he showed it to me, and I felt better about what had happened."
As Kimmel concludes the show, he says, "I don't know what happened. I blame myself for this."
"Let's remember, it's just an awards show," he continues. "I mean, we hate to see people disappointed, but the good news is, we got to see some extra speeches. We had some great movies. I knew I would screw this show up. I really did. Thank you for watching. I'm back to work tomorrow night at my regular show. I promise I'll never come back. Good night!"
PricewaterhouseCoopers issues apology overnight
PricewaterhouseCoopers, the accounting firm that tallies the Oscars voting, said in a statement after the show, "We sincerely apologize to 'Moonlight,' 'La La Land,' Warren Beatty, Faye Dunaway, and Oscar viewers for the error that was made during the award announcement for best picture. The presenters had mistakenly been given the wrong category envelope and when discovered, was immediately corrected. We are currently investigating how this could have happened and deeply regret that this occurred.
"We appreciate the grace with which the nominees, the academy, ABC and Jimmy Kimmel handled the situation."
In a video posted last week to the PricewaterhouseCoopers YouTube page, one of the firm's two co-balloting leaders said, "We have the winners in sealed envelopes that we hold and maintain throughout the evening and hand those to the presenters just before they walk out onstage."
The Academy of Motion Picture Arts and Sciences did not immediately issue a statement.
'La La Land' producer's gracious moment
In the midst of the shocking mix-up, it was Horowitz's gracious words onstage — "I'm going to be really proud to hand this to my friends from 'Moonlight'" — that kept the night moving forward.
He told "GMA" this morning that he "wanted to make sure that the right thing was done."
"Because, you know, at that point it was not about me ... It was about making sure that 'Moonlight' got the recognition it really deserves."
"Those guys are my friends," Horowitz said of the people behind "Moonlight," whom he said he got to know well during the monthslong buildup to the Oscars. "I wanted to make sure they had their moment."
The kind gesture didn't go unnoticed by Jenkins.
"The folks from 'La La Land' were so gracious," he told reporters backstage. "I can't imagine being in their position and having to do that. I wasn't speechless because we won. I was speechless because it was so gracious of them to do that."
ABC News' Morgan Korn, Jeff Costello, Lindsey Jacobson, Lesley Messer and Molly Shaker contributed to this report.