CANNES, France -- The Cannes Film Festival awarded its coveted Palme d'Or award to Ruben Ostlund's Swedish comedy "The Square" on Sunday, while Sofia Coppola became only the second woman to win the best director award.

"Oh my god! OK," the Swedish filmmaker exclaimed after he bounded onto the stage to collect the prestigious Palme, in a rare and somewhat surprising win for a comedy.

In "The Square," Claes Bang plays a museum director whose manicured life begins to unravel after a series of events that upset his, and the museum's, calm equilibrium. The movie's title comes from an art installation that Bang's character is prepping, which invites anyone who enters a small square to be kind and generous.

The film's satire and exploration of moral dilemmas culminated in one of the festival's most eye-catching scenes. A muscled, grunting man pretending to be a gorilla upsets a black-tie dinner for the museum, sniffing attendees and dragging a woman by the hair.

The president of the Cannes jury, Spanish filmmaker Pedro Almodovar, praised the film for exploring the "dictatorship" of political correctness and those trapped by it.

"They live in a kind of hell because of that," Almodovar said.

"It's clever. It's witty. It's funny. It deals with questions so important," said French actress and filmmaker Agnes Jaoui, a member of the jury that also included Americans Will Smith and Jessica Chastain.

Most odds makers didn't have "The Square" as a favourite to win the prestigious Palme d'Or, the top prize awarded at Cannes.

Coppola won best director for "The Beguiled," her remake of Don Siegel's 1971 Civil War drama about a Union soldier hiding out in a Southern girls' school. Hailed as Coppola's most feminist work yet, the remade thriller told from a more female point of view stars Nicole Kidman and Kirsten Dunst, with Colin Farrell playing the wounded soldier.

Coppola was one of three female filmmakers out of 19 in competition for the Palme this year. The first -- and until now, only -- female winner of the best director prize was Soviet director Yuliya Ippolitovna Solntseva in 1961.

Diane Kruger was named best actress and Joaquin Phoenix best actor as the festival celebrated its 70th anniversary.

Kruger was honoured for her performance in Fatih Akin's "In the Fade." She played a German woman whose son and Turkish husband are killed in a bomb attack. The film alludes to a series of actual killings that shook Germany six years ago, when it came to light that police had spent more time investigating the possible mob connections of migrant victims than the tell-tale signs of the far-right plot eventually uncovered.

"I cannot accept this award without thinking about anyone who has ever been affected by an act of terrorism and who is trying to pick up the pieces and go on living after having lost everything," the actress said. "Please know that you are not forgotten."

Phoenix was recognized for his role in Lynne Ramsay's thriller "You Were Never Really Here," in which he played a tormented war veteran trying to save a teenage girl from a sex trafficking ring.

The actor wore sneakers on stage as he collected the prize. He said his leather shoes had been flown ahead of him. He apologized for his appearance, saying the prize was "totally unexpected."

The French AIDS drama "120 Beats Per Minute" won the Grand Prize from the jury. The award recognizes a strong film that missed out on the Palme d'Or.

Directed by Robin Campillo, the co-screenwriter of the Palme d'Or-winning film "The Class," the movie centres on the activist group ACT UP in Paris in the 1990s during the AIDS crisis.

The film's docu-drama retelling of that painful period, combined with a burgeoning spirit of unity for the gay community, earned it some of the best reviews of the festival.

Vanity Fair called the film "a vital new gay classic."

Almodovar said: "I loved the movie."

The jury also presented a special prize to Nicole Kidman to celebrate the festival's 70th anniversary.

Kidman wasn't at the French Rivera ceremony, but sent a video message from Nashville, saying she was "absolutely devastated" to miss the show.

Jury member Smith made the best of the situation, pretending to be Kidman.

He fake-cried and said in halting French, "merci beaucoup madames et monsieurs."

There were no prizes for the first Netflix releases selected to be in competition for the Palme d'Or: Bong Joon-ho's "Okja" and Noah Baumbach's "The Meyerowitz Stories."

Almodovar had made clear beforehand that he didn't want the Palme to go to a movie that isn't shown on big screens. The Netflix selections prompted protests from French movie distributors and led Cannes to rule out, beginning next year, streaming-only films.