Hollywood seized the global platform of the Oscars to take on Donald Trump, but stars kept the tone light and inclusive after the US president's divisive debut.
With Trump famous for his angry Twitter attacks on critics, Hollywood's stars made jibes about incurring his wrath but mostly adopted a celebratory mood, with multiple winners highlighting their origins as immigrants, minorities or foreigners.
"This broadcast is being watched live by millions of Americans and around the world in more than 225 countries that now hate us," the awards' host, Jimmy Kimmel, said in his opening monologue.
The late-night comedian quipped that Trump, who pulled off a political upset win with his campaign that targeted immigration, had taken the heat off Hollywood and its annual gala.
Iran's 'The Salesman' wins Oscar as Farhadi boycotts
"I want to say thank you to President Trump. Remember last year when it seemed like the Oscars were racist? That's gone," Kimmel said.
"We are very welcoming to outsiders here in Hollywood. We don't discriminate on people based on what countries they come from. We discriminate them based on their age and weight," he said.
The top prize went to Moonlight, the coming-of-age story of an African American boy and his struggles with sexual identity -- although the Oscar was announced only after an embarrassing mistake in which feel-good musical La La Land was first announced as the winner.
"This goes out to all those black and brown boys and girls, and non-gender-conforming, who don't see themselves - we're trying to show you," playwright Tarell Alvin McCraney said as he accepted the Oscar for best adapted screenplay.
Iranian director boycotts
Moonlight director Barry Jenkins was one of several nominees to sport a blue ribbon in support of the American Civil Liberties Union, the rights lobby that has been stridently fighting the Trump administration in court.
Also for Moonlight, Mahershala Ali won the Oscar for best supporting actor for his portrayal of a drug dealer.
In perhaps the night's most potent symbol, Iranian director Asghar Farhadi boycotted the gala as his drama The Salesman won for best foreign language film - the second time his work has won that prize.
Farhadi was protesting Trump's visa ban that bars citizens of seven Muslim-majority countries including Iran from entering the United States.
While a court has put Trump's order on hold, the US leader has vowed to bring it back -- and Farhadi vowed solidarity with "disrespected" people.
"Dividing the world into the US and 'our enemies' categories creates fear -- a deceitful justification for aggression and war," he said in the statement read at the gala by the Iranian-born US engineer and astronaut Anousheh Ansari.
Oscars 2017: And the winners are...
"Film-makers can turn their cameras to capture shared human qualities and break stereotypes of various nationalities and religions. They create empathy between us and others - an empathy which we need today more than ever."
Instead of coming to Los Angeles, Farhadi screened his film - a loose adaptation of the classic American play Death of a Salesman that delves into the lives of the actors in Tehran - before thousands of fans in London's Trafalgar Square.
The creators of Zootopia, an animated Disney movie about animals that speak to one another and find ways to coexist, saw a larger message as they accepted the award for best animated feature.
"We are so grateful to the audiences all over the world who embraced this film with this story of tolerance being more powerful than fear of the other," co-director Rich Moore said.
Meryl Streep, who now has a record 20 Oscar nominations, had taken Trump to task in a speech last month at the Golden Globe Awards, pointing in part to his mockery of a disabled journalist.
Trump responded on Twitter that Streep was "one of the most overrated actress in Hollywood" -- a moniker that Kimmel played with as he introduced her at the Oscars.
Oscars 2017 mix-up: Twitter reacts to major 'Best Picture' blunder
"Everybody, please join me in giving her a totally undeserved round of applause, will you? The highly overrated Meryl Streep, everyone," he said.
As the show neared its end, Kimmel feigned disappointment that Trump had not yet weighed in. He took out a phone and tweeted at Trump to ask if he was awake - a message quickly retweeted more than 225,000 times.
Have something to add in the story? Share it in the comments below.