Woody Allen often takes flack for being stuck in the past. That early 20th-century Windsor font he’s used for the opening titles of every film he’s made since 1980 (one per year, like clockwork, apart from a double helping in 1987), coupled with the ever-present classic jazz music not only immediately identifies the films as Allen’s, but hearken back to times long past, no matter when the movie itself is set. His latest, Midnight in Paris, is no different in that respect. But when those titles are over, the film finds Allen inventively criticizing the same brand of nostalgia of which he’s so often guilty.

That could come off as hypocritical. Instead, the result is one of the most charming, funny, and genuinely likable films that Allen’s made in years. And I don’t mean that as faint praise, either: despite his reputation for having spent the last two decades treading water, he’s made some great films during that time. (Alongside, it’s true, some real stinkers.)

Owen Wilson stars in the usual Woody stand-in role as Gil, a Hollywood screenwriter who’s wildly successful at writing vapid entertainment that he hates, despite it having made him rich. What he really wants is to be a novelist, and a visit to Paris with his shallow, materialistic fiancée Inez (Rachel McAdams) finds him enchanted and inspired by the romance of the city, especially when he thinks of its rich artistic history, and the literary and artistic giants who called the city home nearly a century ago. Inez is only impressed by the shopping opportunities Paris affords, and the erudite tours given by her old professor, Paul (Michael Sheen), who they happen to run into one afternoon; Gil’s enthusiastic nostalgia is met with impatient eye rolls.

Wilson does well to avoid the sort of direct mimicry some actors fall prey to when playing the Woody role in one of Allen’s films (cf. Kenneth Branagh, Celebrity), and instead blends his own trademark surfer/stoner naivete with a shot of Allen-esque anxiousness that plays perfectly for the role. It’s Sheen, though, who threatens to steal the show in just a few scenes, relishing the chance to play one of the most hilariously self-involved and hatefully egotistical characters that Allen’s written since Alan Alda in Crimes & Misdemeanors. Sheen’s haughty derision flavors every word he speaks, whether he’s lecturing whomever happens to be around on Rodin or wine.

An unhappy, schlubby artistic type feeling out of place in his own world may feel like boilerplate Allen, and it is, but the left turn that happens every evening at midnight is where the film really takes off. The surprises are such that it would be unfair to reveal too much of the specifics here, but suffice to say that Gil finds a corner where a car will take him back to the 1920s Paris that he holds so dear to his heart. None of this is ever explained, just as the reasons why Jeff Daniels steps out of a movie screen in The Purple Rose of Cairo are never explained; sometimes, magic just needs to remain magical.

These scenes take place in a softly lit, romantic memory of the city — cinematographer Darius Khondji does some stunningly beautiful work here, contrasting the gorgeously gas and candlelit old Paris with the brilliant daylight of the modern sequences. This film is nearly as loving an homage to Paris as Manhattan was to Allen’s home city.

Here, Gil finds people who actually seem to get him, including a stunning art model played by Marion Cotillard. It’s her character that in part makes him realize what a mistake his relationship with Inez is, but it’s also her who shows him the folly of his nostalgia. She feels the same way about the Belle Epoque, and when they take another time traveling jaunt to the late 19th century, he begins to understand the problems with his feeling that the grass is always more sepia-toned on the other side of midnight.

Much more so than his most lauded recent films, Vicky Cristina Barcelona and Match Point, Midnight in Paris feels like classic Allen, in a mode that blends contemplation, philosophy and hilarity in equal measure. The 1920s segments have some of the smartest laugh-out-loud writing he’s done in a long time; film buffs will crack up at the extended riff around Buñuel’s Exterminating Angel. The film’s romantic inclinations are perhaps a little far-fetched, but it’s the kind of implausibility that you deeply want to be true.

But it’s that element of reflexive criticism which makes this truly fascinating, and much deeper, than the light comic fairy tale it appears. If Allen has suddenly realized that looking at the present is much more fulfilling than looking at the past, could that mark a stylistic change in store for the last years of his career? Probably not, but it does perhaps indicate that he’s more self aware than people give him credit for these days. And when he’s still capable of turning out such a thoroughly enjoyable film as this while working in his usual mode, why would he want to change anyway?

Midnight in Paris
Written and Directed by Woody Allen
Starring Owen Wilson, Rachel McAdams, Marion Cotillard, Michael Sheen
Running time: 100 minutes
Rated PG-13 for some sexual references and smoking.
Opens today at E Street, Bethesda Row, Georgetown, Shirlington, and Cinema Arts.

Follow this author on Twitter.