La La Land Thought They Won Best Picture. They Didn't.

Media: MediaOS Video

Sunday night’s Oscar ceremony will probably be remembered for nothing but its last five minutes, which saw the most colossal and embarrassing screw-up in Oscar history. Warren Beatty and Faye Dunaway announced the best picture winner, “La La Land,” and the producers got up and started making their acceptance speeches. Best actress winner Emma Stone was tearing up with joy.

But then, after several speeches, one of the ABC show’s producers interrupted the festivities: Dunaway, handed the card by a confused Beatty, had read out the wrong name. The winner, in fact, was “Moonlight.” It took a moment for the audience to absorb the news. But it was no joke. It was a massive error, the kind that people will be talking about for years.

It seems that Beatty may have been handed the wrong envelope, a duplicate envelope indicating Stone as the best actress winner for her performance in “La La Land.”

“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,” Beatty explained with a shrug. “I wasn’t trying to be funny.”

It could have been a printing error, or maybe there’s an intern who is not going to be back next year. In any case, it made for excruciating live television: The “La La Land” producers were put in the position of having to hand their Oscars over to the “Moonlight” producers.

“Even in my dreams this cannot be true,” said an astonished Barry Jenkins, once he reached the stage. “But to hell with dreams! I’m done with it. This is true.”

Host Jimmy Kimmel tried to make light of the situation saying, “Personally, I blame Steve Harvey for this,” referring to Harvey’s error when he named the wrong Miss Universe in 2015.

But producer Jordan Horowitz showed that he and his “La La Land” crew aren’t sore losers, announcing onstage, “I’m gonna be really proud to hand this to my friends for ‘Moonlight.’”

“Let’s just remember, it’s just an award show,” Kimmel said. “I knew I would screw this show up. ... I promise I’ll never come back.”

But it was the worst way to lose an Oscar, and the worst way to win one. And it provided an embarrassing spectacle broadcast throughout America and the world: We can’t even get the Oscars right.

Aside from that horrible moment of devastation, it was actually a good night for “La La Land.” (Though to say that calls to mind the old joke: “Aside from that, Mrs. Lincoln, how did you like the play?”) It was the big winner, picking up six Academy Awards, including best director, best score and best actress. It went into the night nominated for 14 categories, tied with “Titanic” and “All About Eve” for most nominations.

It was also a good night for African Americans, with black artists winning in both supporting categories and for best adapted screenplay. And with a film made by and about African Americans, “Moonlight,” taking the best picture prize. This is a big shift from last year, when no black actors were nominated in any of the acting awards.

Casey Affleck won best actor for his performance in “Manchester by the Sea,” as a man whose life has been derailed by grief and calamity. The film also picked up a best original screenplay prize for the script by Kenneth Lonergan.

Stone, in her acceptance speech, called it “a confluence of luck and opportunity.” She thanked her director, Damien Chazelle, who minutes before had won his own Oscar. At 32, he became the youngest winner for best director.

The relative dominance of “La La Land” was expected. What was also expected going into the night was that President Trump would be the night’s main topic of conversation. Many of the stars in the auditorium wore blue ribbons, in honor of the American Civil Liberties Union, and emcee Kimmel kicked things off early: His first Trump reference came 61 seconds into his opening monologue, and he mentioned the president by name two minutes later.

In total, Trump was referenced 14 times from the stage Sunday night, and it can be safely said that no American president has ever been the subject of more scorn at an Academy Awards ceremony. At one point, Kimmel alluded to Trump tweeting “during his 5 a.m. bowel movement.”

Yet, the serious commentary that was expected was largely absent. There was no equivalent of Meryl Streep’s Golden Globes speech, in which she went after then President-elect Trump directly. Instead, Kimmel’s jokes aside, there were only a few scattered moments. The Mexican actor Gael Garcia Bernal spoke out against building walls between people, and Jenkins, in winning the award for best adapted screenplay for “Moonlight,” addressed marginalized communities and said, “We have your back for the next four years.”

Most dramatically, but predictably, the best foreign film victory of “The Salesman,” from Iran, brought about a statement from its director, Asghar Farhadi. In a statement read by a spokesman, Farhadi said, “My absence is out of respect for the people of my country and those of (the) other six nations who have been disrespected by the inhumane law that bans entry of immigrants into the United States.”

Viola Davis (“Fences”) won best supporting actress with an emotional and beautiful spoken speech, which began with her talking about her calling as an actress. “I became an artist, and thank God I did, because we are the only profession that celebrates what it means to live a life.” Davis, in all of her acceptances on the way to this one, has not been afraid to talk about the artist’s life and to assert its value within the culture, and in the most passionate terms. Each time, it’s a nice moment of self-revelation.

Mahershala Ali won best supporting actor for his role as a sympathetic crack dealer in “Moonlight.” He thanked his teachers and his professors, who taught him that “it’s not about you, it’s about these characters. You’re in service to these characters.”

“Zootopia” won best animated feature, and best animated short went to Pixar’s “Piper.”

But in the end, the whole night will go down in history as a footnote, and those last five minutes will be remembered for as long as anybody cares about the Oscars. What happened Sunday was jaw-dropping, as rare as a triple play or a perfect game in baseball. No one who saw it will ever forget it.

Indeed, Sunday night is the one night it would have been nice to be a fly on the wall at the Governor’s Ball. The gossip must have been flying.

Mick LaSalle is The San Francisco Chronicle’s movie critic. Email: mlasalle@sfchronicle.com Twitter: @MickLaSalle