The coming-of-age drama Moonlight has won the Academy Award for best picture in an extraordinary Oscar upset and an unprecedented gaffe that saw one winner swapped for another.

While announcing the top honour of Sunday's event, an apparent mix-up of cards created uproar and confusion in which presenters Faye Dunaway and Warren Beatty initially declared smash hit musical La La Land the winner.

OSCAR WINNERS 2017: Best Picture: Moonlight Best Directing: Damien Chazelle - La La Land Best Actress: Emma Stone - La La Land Best Actor: Casey Affleck - Manchester by the Sea Best Supporting Actress: Viola Davis - Fences Best Supporting Actor: Mahershala Ali - Moonlight Foreign Language Film: The Salesman (Iran) Animated Feature Film: Zootopia Documentary Feature: OJ: Made in America Live Action Short Film: Sing Animated Short Film: Piper Documentary Short Subject: The White Helmets Cinematography: La La Land Adapted Screenplay: Moonlight Original Screenplay: Manchester by the Sea Original Score: La La Land Original Song: City Of Stars - La La Land Sound Editing: Arrival Sound Mixing: Hacksaw Ridge Production Design: La La Land Visual Effects: The Jungle Book Film Editing: Hacksaw Ridge Costume Design: Fantastic Beasts and Where to Find Them Make-up and Hairstyling: Suicide Squad

But as La La Land's producers were accepting the award, they were interrupted for a highly unusual correction: La La Land was not the winner, Moonlight was.

A chagrined Beatty blamed the flub on the envelope, which he said had contained a duplicate of the card for the best actress trophy.



"I opened the envelope and it said Emma Stone, La La Land," he said. "I wasn't trying to be funny."

Host Jimmy Kimmel had come forward to inform the cast that Moonlight had indeed won, showing the inside of the envelope as proof. "I knew I would screw this up," said Kimmel, a first-time host.

"I promise to never come back."

Producer Jordan Horwitz then graciously passed his statue to the Moonlight producers.

Al Jazeera's Andy Gallacher, reporting from Los Angeles, said there was complete chaos after the error and people were confused.

"This was not exactly the Hollywood ending," he said.

"As the La La Land crew got on stage to receive the award, one of the members put up the card to the camera and said this is not a joke, Moonlight won."

"The mistake has overshadowed the entire awards night. Now the only thing people will remember is this monumental mistake, which was ... great news for Moonlight and bad news for La La Land," Gallacher said.

The best picture award was the third Oscar for Barry Jenkins' film about an African American boy growing up gay in a poor neighbourhood in Miami.

Moonlight also won best supporting actor for Mahershala Ali - the first Muslim actor to win an Oscar - and best adapted screenplay for Jenkins and Tarell Alvin McCraney.

The film has won plaudits as a vital portrait of contemporary African American life and is praised in equal measure as a groundbreaking and personal meditation on identity, family, friendship and love.

Besides La La Land, Moonlight beat seven other films, including alien thriller Arrival and family dramas Manchester by the Sea and Fences for best picture honours.

La La Land, however, still collected a leading six awards, including honours for cinematography, production design, score, the song City of Stars and best director for Damien Chazelle, who at 32 became the youngest filmmaker to win the category.

La La Land star Emma Stone also won best actress for her portrayal of an aspiring actress forced to endure the indignities of failed auditions, while Manchester by the Sea star Casey Affleck was named best actor for his performance as a taciturn janitor with a troubled past.

"Man, I wish I had something better and more meaningful to say ... I'm just dumbfounded that I'm included," said Affleck, a first-time Oscar winner.

Viola Davis, meanwhile, won her first Oscar for her supporting roles in Fences. The wins of Davis and Ali marked the first time in more than a decade that multiple Oscar acting honours went to black actors.

Earlier in the show, US President Trump had been the target of numerous jokes, capping an awards season marked by fiery protests by celebrities at his policies.

Kimmel fired off political zingers and even tweeted at the Republican president, getting no immediate response.

Insisting he was at a loss for words to help unite a divided country, the host exhorted viewers to make their own efforts at reconciliation by reaching out to political adversaries they knew personally to "have a positive, considerate conversation, not as liberals or conservatives, as Americans.

"If we could all do that, we could make America great again," he said, an allusion to Trump's own campaign slogan.

Kimmel also showed a willingness to tweak the motion picture academy for its own shortcomings, drawing a sly parallel between the criticism both the president and the Oscars have taken for a perceived lack of racial sensitivity.

"I want to say, 'Thank you, President Trump,'" he said. "I mean, remember last year when it seemed like the Oscars were racist?" he asked rhetorically in a reference to the #OscarsSoWhite controversy which clouded the Academy Awards in 2016.

Several celebrities wore blue ribbons on Sunday in support of the American Civil Liberties Union advocacy group that worked to get Trump's bid to ban travellers from seven Muslim-majority nations blocked in US courts.

But for the most part, speeches at the ceremony were mild or made general pleas for tolerance rather than directly attacking Trump.