In a stunning upset, “Moonlight,” a drama about a gay man in the inner city, scored best picture at the 89th Academy Awards, beating out the heavily favored “La La Land.” The low-budget film’s victory was made even more shocking after presenters Warren Beatty and Faye Dunaway mistakenly read out “La La Land’s” name as the victor. Chaos reigned, as the “La La Land” producers took the stage to thank family and colleagues, before Beatty acknowledged that he had been given the wrong envelope and “Moonlight” was crowned the winner.

“La La Land,” a celebration of all things Los Angeles, had seemed like both a hometown favorite and an insurmountable front-runner. It had previously picked up top prizes at the Golden Globes, the Producers Guild and the Directors Guild, and entered the evening with 14 nominations, tying a record set by “Titanic” and “All About Eve.”

This year’s awards wasn’t just about an Oscar flub for the ages, one that left many in the audience open-mouthed in disbelief. It was also one of the most politically charged telecasts in history, unfolding as much of Hollywood remains opposed to President Donald Trump. Winners and presenters used their time at the podium to vocalize their dissent, decrying the administration and its support of the Muslim ban, the border wall with Mexico, and other right-wing policies. Many of the A-listers sported pins for organizations like Planned Parenthood and the American Civil Liberties Union that have been on the front lines of the culture wars currently roiling the country.

The telecast wasn’t all about tearing down Trump and Trump-ism. It was also a celebration of diversity and inclusion, both in the selection of “Moonlight,” a tender coming-of-age story, and in the record-shattering number of black winners who took the stage. “Moonlight’s” Tarell Alvin McCraney, spoke to the desire to hear from under-represented voices while accepting a best adapted screenplay Oscar, one of three statues that the film won.

“This goes out to all those black and brown boys and girls and non-gender conforming who don’t see themselves,” said McCraney. “We’re trying to show you and us.”

“La La Land” didn’t go home empty-handed. It still picked up a leading six statues, including one for Damien Chazelle, the 32-year old wunderkind behind the film. He became the youngest-ever best director winner in history, and was honored for helping to revive the musical, a film genre that has fallen out of favor in a movie business obsessed with superheroes and franchises.

Best actress winner Emma Stone beat out the likes of Isabelle Huppert (“Elle”) and Meryl Streep (“Florence Foster Jenkins”) to earn her first Oscar for her singing and dancing turn in “La La Land.”

“A moment like this is a huge confluence of luck and opportunity,” Stone said, while thanking Chazelle for casting her in the project. She becomes the first best actress winner for a musical since Liza Minnelli picked up the honor for “Cabaret” in 1973.

Casey Affleck, sporting a scruffy beard and ruffled hair, picked up a best actor statue for his role as an emotionally damaged janitor in “Manchester by the Sea,” coming out ahead of Denzel Washington, who had been favored to win for his work as an abusive patriarch in “Fences.” The winner paid tribute to the man he beat in his acceptance speech.

“One of the first people who taught me how to act was Denzel Washington and I just met him tonight for the first time,” Affleck said. The actor’s candidacy faced a backlash after sexual harassment allegations against Affleck resurfaced. He was previously accused of harassing two women on the set of 2010’s “I’m Still Here,” and eventually settled the lawsuits out of court.

Affleck’s award was one of two for the film, the first Oscars won by Amazon Studios, a streaming service that is helping to upend the old way of distributing and profiting from films.

Mahershala Ali and Viola Davis nabbed supporting acting honors. Ali was recognized for his work as a sympathetic drug dealer in “Moonlight,” while Davis picked up her first statue after two previous nominations for playing a long-suffering wife in “Fences.”

Fighting back tears, Davis praised playwright August Wilson, the author of “Fences,” for creating a work that “exhumed and exalted the ordinary people.”  She is now the first African-American to win acting prizes at the Oscars, Tonys, and Emmys.

Ali broke ground as well, becoming the first Muslim actor win an Oscar. In an emotional speech, Ali thanked his acting teachers, director Barry Jenkins, and paid tribute to his newborn daughter. Davis and Ali’s wins come after two years of protests related to the lack of racial diversity among top acting nominees.

The Academy of Motion Picture Arts and Sciences has been trying to demonstrate that it has heard the outrage and responded to the hurt expressed by the #OscarsSoWhite campaign. Seven of the twenty performers up for awards this year are actors of color, and films like “Moonlight,” “Hidden Figures,” and “Fences” all dealt with race in America. In response to the furor, the Academy took steps to shake up its membership roles, with the goal of doubling the diversity of the voting body by 2020.

Host Jimmy Kimmel wasted no time poking fun at the current White House occupant. “This broadcast is being watched live by millions of Americans and around the world in more than 225 countries that now hate us,” he said during his opening monologue.

“I want to say thank you to President Trump — remember last year when it seemed like the Oscars were racist?,” he added. “That’s gone, thanks to him.”

At times the broadcast played like voices of the opposition, as winners praised the immigrant experience, spoke out about the carnage in Syria, and hailed religious tolerance. In her remarks, Academy President Cheryl Boone Isaacs argued that art bridges cultural barriers and that the film business is a globalized one that draws power from diverse voices.

“Tonight is proof that art has no borders, art has no single language, and art does not belong to a single faith,” said Isaacs. “For the power of art is that it shares all these things.”

The antipathy toward Trump was also evident in the selection of winners. Iranian director Asghar Farhadi picked up an Academy Award for best foreign-language movie for “The Salesman,” but was not present at the ceremony in protest for the president’s visa ban for citizens from Iran other Muslim countries. In a statement, Farhadi slammed the policy as inhumane and argued that “dividing the world into the us and our enemies categories creates fear.”

Ezra Edelman, the director of best feature documentary winner “O.J.: Made in America,” waded into other hot-button issues, using his time at the microphone to dedicate his statue to “… the victims of police violence, police brutality, racially motivated violence and criminal justice.”

The politicized tone extended to the commercials, with ads for Revlon and Cadillac seemingly more interested in discussing filling the social chasm between “blue” and “red” America than in hawking beauty products or SUVs. The New York Times, the subject of intense criticism from the president, who has labeled it “fake news,” also took out a TV spot during the show. Its message: the truth is hard.

In addition to Affleck’s win, “Manchester by the Sea” picked up an original screenplay Oscar for Kenneth Lonergan, its writer and director. The film marks a comeback for Lonergan, who spent years in the professional wilderness after his previous film, “Margaret,” became entangled in a legal fight.

Beatty and Dunaway’s appearance will be remembered for the best picture do-over, but it had a deeper resonance. The two reunited on stage some fifty years after they helped usher in a new era of cinema with “Bonnie and Clyde” — a kind of filmmaking that was iconoclastic and that brought a new vitality to a form of entertainment that had seemed to be teetering. That film emerged as the studio system was on its last gasps, brought low by the rise of television.

Now a different kind of revolution is gripping the industry. This year’s Oscars ceremony comes as digital players like Amazon and Netflix are transforming the ways that consumers view, rent, and buy movies, and moviegoers are shunning theaters for the comfort of the couch. It is also a time when the major studios have largely abandoned the personal, filmmaker-driven projects that the Academy tends to reward in favor of slices of intellectual property that can be turned into theme park rides and toy lines.

Aside from “La La Land” and “Hidden Figures,” both of which crossed the $100 million mark domestically, this year’s crop of nominees were only modest box office performers. “Moonlight” may be a financial success, having grossed more than $20 million on a $1.5 million budget, but that’s a fraction of what a studio tentpole can make in a weekend. It was also backed by A24, an upstart indie that has produced the likes of “Room” and “20th Century Women.”

Blockbusters like “The Jungle Book” and “Star Wars: Rogue One,” the kinds of films studios like to greenlight, were consigned to technical categories. That means that many viewers are unfamiliar with the films taking home the major prizes. That could translate into lower ratings — a perpetual problem for an awards show with an aging audience. Last year’s telecast, which was hosted by Chris Rock, had the smallest audience in eight years, with 34 million viewers.

“Zootopia,” was one of the few popular smashes to get awards love on Sunday. The animated allegory about animal cops and small-time crooks battling inter-species prejudices nabbed a best animated feature honor.

This is Kimmel’s first turn as the show’s emcee. The comic tried to strike a chummy tone throughout the program, joking with Jeff Bridges about his vape pen and papering the crowd at the Dolby Theatre with Junior Mints and Red Vines. At another point he welcomed a bus filled with tourists into the theater, and let them take selfies with Denzel Washington and Meryl Streep.

Kimmel’s presence is a tidy piece of corporate synergy. The late night comic’s show airs on ABC, the same network that broadcasts the Oscars. In an effort to appeal to younger crowds, the Oscars keeps cycling through hosts, such as Ellen DeGeneres, Seth MacFarlane, and Neil Patrick Harris, with few making return engagements.

“This is my first time here and the way you people go through hosts, it’s probably my last time here,” Kimmel quipped at one point.