Image copyright EPA Image caption Warren Beatty with the envelope he should have opened

Critics often say that the best picture Oscar goes to the wrong film. But the 2017 Oscars will forever be remembered as the year it literally did.

Until the very last award, the Oscars, hosted by first-timer Jimmy Kimmel with an all-new production team, had been pretty much as expected - political, long and often funny, but with some set-pieces that really tested the patience.

But, instead of Gael Garcia Bernal's impassioned words on the US-Mexico border wall or the Chicago couple being "married" by Denzel Washington, the production mistake and the resulting chaos is going to be all anyone talks about.

What seems to have happened is that Warren Beatty, who along with Faye Dunaway was announcing the award, was mistakenly given the best actress envelope - the prize that had moments earlier been given to La La Land's Emma Stone.

"I blame myself for this," Kimmel said, as he realised it was absolutely falling apart around him. "I knew I would screw this show up. I promise I'll never come back."

In actual fact, however, Kimmel had done a perfectly decent job.

The first Oscars after President Trump's election was expected to be a political affair. Yet while there was an element of that, it was somewhat less pointed than some had thought - with more emphasis on togetherness than division.

It was opened, not by Kimmel, but by Justin Timberlake performing Can't Stop the Feeling from Trolls. A number of stars got up and gave it a bit of early-show shuffling, but you could tell their hearts weren't quite in it.

Image copyright Reuters Image caption Pharrell Williams with Justin Timberlake during the show's opening number

Then it was over to Kimmel and the always anticipated opening monologue. After a thank you to Timberlake - "I hope the other guys from N*Sync were watching that performance, because if they were there's a really good chance they'll let you back in the band" - it was on to the real (Republican) red meat.

The ceremony was being watched live in "more than 225 countries that now hate us," Kimmel said.

"I wanted to say thank you to President Trump. I mean, remember last year when it seemed like the Oscars were racist?" he added, in one of the night's more pointed lines.

In one of the night's best jokes, he nodded to Hidden Figures and La La Land in saying that this was the year when "black people saved Nasa and white people saved jazz".

Image copyright Getty Images Image caption Matt Damon, pictured with Ben Affleck, was the target of several Kimmel jibes

Trump is of course a broad target and some of the political material was rather too obvious. That the President sends tweets in the middle of the night is hardly a new observation.

"We don't discriminate against people based on where they come from. We discriminate against them based on their age and weight," was somewhat more typical.

What was funnier was the running joke about Kimmel's hatred of Matt Damon, mocking him for leaving the role that won Casey Affleck best actor to be in "a Chinese ponytail movie" - The Great Wall - "that lost $80m".

And a series of rather dull mini-films in which directors spoke about the films that had inspired them had a great pay-off - Kimmel himself talking about how he had been "inspired" by Damon's lacklustre We Bought a Zoo.

Other repeated memes included snacks descending on parachutes from the rafters to the sound of Ride of the Valkyries.

Image copyright Reuters Image caption Snacks descended on parachutes at various points in the show

Then there was the bit with the tourists, when a bus-load of people who thought they were just taking a standard evening tour of Hollywood Boulevard found themselves right in the middle of the ceremony.

The first two in, a couple named Gary and Jackie from Chicago, were engaged, so Kimmel arranged for Denzel Washington to "marry" them. ("That's Denzel so it's legal.") Jackie even got Jennifer Aniston's sunglasses as a wedding present.

Whether you thought this was a charming bit of Surprise, Surprise or an embarrassing, drawn-out fiasco in which "normal" people were paraded in front of the celebrities like some sort of human zoo depended on your level of cynicism.

Kimmel also worked the Mean Tweets feature from his usual show into the Oscars, which paid off really well - especially the dog that looked like Tilda Swinton. (It really did.)

Image copyright Getty Images Image caption Tilda Swinton was among the celebrities in the Mean Tweets segment

He did far more work than hosts usually do, picking up between pretty much every award. It meant he needed more material, which varied in quality but did have some great zingers.

"Just because a screenplay is adapted doesn't mean we love it any less" was right up there.

The one that elicited the most groans, however, was "the only happy ending in all of the nominees was the one in the middle of Moonlight".

At the time it was a throwaway line. But how prescient that Moonlight's happy ending in fact came in the middle of La La Land's - an unscriptable Hollywood moment, however Trumplesome the production.

Follow us on Facebook, on Twitter @BBCNewsEnts, or on Instagram at bbcnewsents. If you have a story suggestion email entertainment.news@bbc.co.uk.