The producers of “La La Land” were still thanking their families and fellow artists when the interjection came that “Moonlight” had in fact won, as everyone wondered if that was a joke. But it wasn’t, and the “La La Land” people quickly exited the stage as producers and stars of “Moonlight,” just as stunned as everyone else, walked on.
Warren Beatty and Ms. Dunaway had presented the best picture award. When Mr. Beatty opened the envelope, he took an extended pause before showing the card to Ms. Dunaway, who then announced “La La Land” as the winner.
“I want to tell you what happened,” Mr. Beatty said in the chaotic moments after “Moonlight” was announced as the winner. “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. This is ‘Moonlight,’ the best picture.”
“Moonlight,” the story of a young, gay, black man, won three statuettes in total, including best adapted screenplay and best supporting actor.
“Very clearly, even in my dreams this could not be true,” said Barry Jenkins, the director of “Moonlight.” “But to hell with dreams, I’m done with it, because this is true. Oh my goodness.”
Held up as an escapist, believe-in-yourself antidote for the times, the neo-musical “La La Land” won six Oscars, including statuettes for Damien Chazelle’s directing and Ms. Stone’s acting, during a jaunty ceremony that swung between self-celebration and political acrimony — before its wild ending.
“It threw me more than a bit,” Mahershala Ali, who won best supporting actor for “Moonlight,” said backstage. “I just didn’t want to go up there and take anything from somebody, you know?”
PricewaterhouseCoopers, the accounting firm that handles the Oscars balloting, took responsibility for the mixup. “We sincerely apologize to ‘Moonlight,’ ‘La La Land,’ Warren Beatty, Faye Dunaway and Oscar viewers for the error,” the firm said in a statement. 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.”
ABC News tweeted out a photo that showed that the envelope in Mr. Beatty’s hand read “Actress in a Leading Role.”
After the show, Ms. Stone said on ABC that she had held onto the envelope with the card bearing her name after she won best actress.
In a blog post published on Medium this month, Brian Cullinan and Martha Ruiz of the firm PricewaterhouseCoopers, explained the process of handling the envelopes for the Oscars. Mr. Cullinan wrote that he and Ms. Ruiz each had a full set of envelopes and stood on opposite sides of the stage, where they handed envelopes to presenters.
“It doesn’t sound very complicated,” Mr. Cullinan said, “but you have to make sure you’re giving the presenter the right envelope.”
Here are other notable moments from the show:
Diverse Set of Winners
“Hacksaw Ridge,” the true story of a heroic World War II medic, won Oscars for sound mixing and film editing, a category that is often predictive of the best picture winner. Kenneth Lonergan won the best screenplay statuette for his “Manchester by the Sea,” the story of a grieving New England handyman. Casey Affleck, who played the lead role in Mr. Lonergan’s film, beat Denzel Washington (“Fences”) for best actor.
“I’m just dumbfound I’m included,” Mr. Affleck said.
The supporting acting prizes went to Viola Davis for her work in “Fences,” about a Pittsburgh family in the 1950s, and Mr. Ali for his portrayal of a sympathetic drug dealer in “Moonlight,” which also collected the adapted screenplay Oscar, for Mr. Jenkins and Tarell Alvin McCraney.
“All you people out there who feel like there’s no mirror for you, that your life is not reflected, the academy has your back, the A.C.L.U. has your back, we have your back — and for the next four years, we will not leave you alone, we will not forget you,” Mr. Jenkins said from the stage.
Prizes for Viola Davis and Mahershala Ali
As expected, Ms. Davis won the best supporting actress Oscar — her first — for playing a world-weary housewife in “Fences.” (She won best actress at the 2010 Tony Awards for playing the same role onstage. She was the one who decided to drop to the supporting category for the Oscars.)
An intense, nearly overcome Ms. Davis touched on her family, her industry “cheerleaders,” the film’s director (Mr. Washington), graveyards, dashed dreams and the playwright August Wilson, who adapted his “Fences” for the screen and whom Ms. Viola praised as someone who “exhumed and exalted the ordinary people.”
The night’s first award went to Mr. Ali, who tearfully thanked the cast and crew of “Moonlight” and his own family. “Peace and blessings,” he said, avoiding a repeat of the pointed comments he made at previous awards shows about the Trump administration’s travel ban.
After two years when the Academy of Motion Picture Arts and Sciences was criticized as racist for overlooking black actors and films about African-American experiences, this year’s nominee list was remarkably diverse. Six black actors received nominations, a record.
Issues Play a Major Role
The foreign film and documentary races were notably relevant this year.
Among foreign films, the German satire “Toni Erdmann” initially had the momentum. But Mr. Trump’s travel ban put the spotlight on Iran’s entry, “The Salesman,” whose director, Asghar Farhadi, said that he would boycott the ceremony in protest — a decision that may have ultimately helped his film win.
Anousheh Ansari, an American-Iranian businesswoman, accepted the award for “The Salesman” and read a message from Mr. Farhadi. The note said that he was not attending in solidarity with immigrants “who have been disrespected by the inhumane law,” referring to the Trump administration’s travel ban.
Among nonfiction films, Ava DuVernay’s much-esteemed look at mass incarceration, “13th,” was campaigned for aggressively by Netflix, and the civil rights-themed “I Am Not Your Negro” surged late in the season. But the nearly eight-hour is-it-a-mini-series-or-is-it-a-film “O. J.: Made in America” was named best documentary. In accepting the award, Ezra Edelman, the film’s director, dedicated the Oscar to Nicole Brown Simpson, Ronald Goldman and “the victims of police violence, police brutality, racially motivated violence and criminal injustice.”
A Host’s Balancing Act
Mr. Kimmel, an Everyman schtick carefully in place, opened his monologue by asking viewers, both conservative and liberal, to come together in a calm conversation. “If we could all do that we could make America great again, we really could,” he said, to applause. Mr. Kimmel, appearing confident and calm — and with the A-list audience, munching on Red Vines and Junior Mints, now firmly on his side — soon took sharper aim. In a reference to President Trump, Mr. Kimmel said, “Remember last year, when it seemed like the Oscars were racist?”
As the ceremony went on, organizers played up Hollywood glamour and paid homage to Academy Awards history. Music interludes were taken from the scores of “Top Gun” and “Tootsie.” Shirley MacLaine appeared as a presenter, joking that the standing ovation was “the nicest reception I’ve had in 250,000 years.” At one point, Mr. Kimmel trotted out a tour bus full of unsuspecting tourists, to mixed results.
But politics was a consistent topic. Gael García Bernal, presenting best animated film to “Zootopia,” said, “As a Mexican, as a Latin American, as a migrant worker, as a human being, I am against any form of wall that wants to separate us.”
Left to bridge the gap between people watching from their sofas in Kansas City and the theater filled with coastal elites was Mr. Kimmel.
In a moment that certainly checked the populist box, the busload of unsuspecting Hollywood tourists, selfie sticks aloft, found themselves ushered into the Dolby Theater, and shuffled before Hollywood A-listers and the world. The bit, which went on at some length, drew a polarizing response on social media, with some viewers criticizing Mr. Kimmel for exploiting the tourists and mocking an Asian woman’s name.
Later, Mr. Kimmel joked that President Trump had not tweeted about the show. So Mr. Kimmel typed out a tweet to the president on his phone: “Hey @realDonaldTrump u up?”
An earlier version of this article misspelled the surname of the screenwriter and director of “Manchester by the Sea.” He is Kenneth Lonergan, not Longergan.
A picture caption with an earlier version of this article misstated the award that Casey Affleck received. It was for best actor, not best picture.