“Picasso at the Lapin Agile” feels like a Steve Martin stand-up routine grafted onto a fun, if flimsy, plot: a pair of twenty-something no-names — a painter and a physicist — meet at a Paris bar in 1903. One is called Picasso and the other is named Einstein, and they spend the night exchanging jokes, competing for women’s attention and announcing their plans to revolutionize the 20th century. The play was Martin’s first, written in 1993.

Each role in this delightful farce is a Martin alter ego embodied — a comic conceit come to life — and the actors in Long Wharf Theatre’s excellent new production have obviously studied Martin’s mannerisms: More than a few lines are inflected with the comedian’s trademark loopy delivery.

The subject matter is uneven. Bathroom humor is unceremoniously thrown together with overwrought soliloquies about the nature of genius, but the powerhouse cast is able to take an already-charming script and wring out a moving and uproariously funny play.

A married couple — Freddy (Tom Riis Farrell) and Germaine (Penny Balfour) — run the Lapin Agile. Among their guests are Gaston, an old man whose perversion is rivaled only by his incontinence; Suzanne, a beautiful young woman eager for a tryst with Picasso; and Sagot, an art dealer whose money-mindedness serves as a foil to Picasso’s romantic idealism.

Freddy and Germaine are ordinary compared to their larger-than-life guests, but they too have their outré moments: a shouting match over whether Germaine is a post- or neoromantic is interrupted by Gaston, who reminds them, “This is not some sleazy dive!”

The show’s greatest comic pleasure is Jonathan Spivey in the tremendously idiotic role of Charles Dabernow Schmendiman, an inventor who is confident that his building material — a mixture of asbestos, kitty paws and radium — will guarantee him a prominent place in the 20th-century pantheon. Onstage for 10 captivating minutes, he is the play’s strongest invention — even if the joke can only be sustained for a short burst.

Einstein, in the hands of Robbie Tann, is also delightfully weird, prancing and cackling his way through the 85-minute show. Picasso (Grayson DeJesus) is a caricature of the appallingly self-obsessed artist: picture James Franco or Kanye West at their most cringe-inducingly pretentious.

The rapport between the two men is the backbone of the play: Already convinced of his own genius, each man gradually becomes convinced of the other’s, too, until they are awash in a sea of self-congratulation, shouting lines like “My only regret is that we’ll be in different volumes in the encyclopedia!”

Perhaps here it is appropriate to note that the play’s armchair philosophizing is on a par with Christopher Nolan’s “Interstellar”: Orations on the subjectivity of the universe are either rousing or woefully out of place, depending on your mood.

Over and over, it is pointed out that the 20th-century revolutions in physics and art both involved a radical relativism — which is an idea, sure, just not a remotely original one. Granted, no one expects Steve Martin to be Tom Stoppard, and his effort to dramatize an historical moment is perfectly admirable.

Thankfully, there is an endless stream of goofy, meta-referential moments and absurd tangents: When Suzanne coyly asks Picasso when he will return to his room, he answers, “When the play is over.” Einstein seeks to explain why “e” is the funniest letter, individually assessing every other letter in the alphabet to prove his point.

The audience’s knowledge of history provides another rich vein of humor, as when Germaine offhandedly predicts the advent of air travel, television, the atomic bomb, computers and lawn flamingos — before being dismissed by her husband as foolish.

The futuristic bell that chimes whenever anyone enters or exits the bar is a subtle clue that the bar exists in a special realm unto itself. But any subtlety on this front is left in the dust in the play’s final sequence, when the bar’s magical qualities are brought to the fore in a preposterous finale that only Steve Martin would dare to include. No spoilers here!

Suffice it to say that the play is an idiosyncratic love letter to the 20th century. It darkly hints at the impending world wars, but also seems to hold up Picasso and Einstein as secular saints — individual minds whose elegance might be capable of redeeming the century’s legacy. Steve Martin might not belong in their rarefied air, but even as a rookie playwright, he has created an enduring work of his own.