It’s 1864, and Artemus Ward, a comic journalist who has joined the lecture circuit because it pays better than scribbling, is playing Virginia City, Nev., a boomtown perched on top of the Comstock Silver Lode. Along with a few other boozers, he and his new buddy, a local reporter who signs himself Mark Twain, have put in such a strenuous night of pub-crawling (and the close-packed streets of Virginia City offer plenty of pubs to crawl) that the sun is coming up.

“Suddenly, Ward broke away from the group and clambered up onto the roof of a miner’s shack. ‘I can’t walk on the earth,’ he shouted. ‘I feel like walking on the skies.’

“Twain climbed up and joined him. Then Ward leaped across to a new roof. Twain followed. As dawn broke . . . the pair just kept leaping. Ward and Twain, roof to roof.”

That episode is recounted in “Rebel Souls,” Justin Martin’s history of a Manhattan tavern called Pfaff’s and the bohemians who hung out there during its heyday in the 1850s. The book is rife with such scintillating anecdotes.

Located on Broadway just north of Bleecker Street, Pfaff’s was owned by a man named, unsurprisingly, Pfaff. But its guiding light was Henry Clapp, an American wit who had spent time in Paris with the original bohemians (unless you count citizens of the actual kingdom of Bohemia): the down-at-the-heels painters and writers whose stories were to inspire Puccini’s opera “La Bohème.” The small-b term “bohemians,” Martin explains, derived from confusion as to where gypsies — long stereotyped as ne’er-do-wells — originally came from.

’Rebel Souls: Walt Whitman and America's First Bohemians’ by Justin Martin (Da Capo)

Clapp went home eager to found and nurture a salon, and Pfaff was happy to make his basement-level bar available. It was divided into two rooms, one for the salon-within-a-saloon of which Clapp was ringmaster, the other for gay men looking for others like themselves. The most illustrious Pfaff regular moved back and forth between the two sectors. His name was Walt Whitman.

Other denizens included Ward (real name Charles Farrar Browne); Fitz-James O’Brien, remembered today (if at all) for his ghost story “What Was It?”; Fitz Hugh Ludlow, who drew on personal experience to write a book called “The Hasheesh Eater”; and Adah Isaacs Menken, an actress who achieved fame by taking off as many of her clothes as 19th-century morality allowed and who produced her most thrilling effects by capering about in a flesh-colored body stocking.

Clapp presided over this human collage by virtue of his personal connections and his way with a quip. Dependent as they are on inspiration in context, oral wisecracks can have a short half-life, but at least one of Clapp’s holds up fairly well today. At a New York lunch with William Dean Howells, editor of the Atlantic, Clapp listened while Howells told of meeting Nathaniel Hawthorne and lamented their mutual shyness. “Clapp pulled his pipe from his mouth,” Martin writes, and “waited the perfect measure, before delivering: ‘Oh, a couple of shysters.’ ”

But the title of Funniest Bohemian goes to Ward, one of whose zaniest stage bits was to launch into a tale only to have his accompanist immediately drown him out with loud piano-playing. Ward kept mouthing his lines, supposedly unaware that the audience couldn’t understand a word. When the pianist finally stopped, Ward’s voice rang out with a concluding fragment: “. . . and she fainted on Reginald’s breast.” Then the pair repeated the whole fiasco from start to finish.

Mark Twain was not a Pfaff habitué, but he got into the act as Ward’s admirer and disciple — Twain’s one-man shows owed more than a little to his mentor’s example. Martin tells a revealing story about Ward’s opening night in Virginia City, when one member of the audience kept throwing Ward’s timing off by laughing a few seconds after everyone else. Ward thought this might be a form of heckling. Not so, Martin explains. The late laugher was from Twain, who “was studying Ward’s act with incredible focus and intensity. First, he was processing Ward’s peerless technique. . . . Then, a few beats later, he was letting himself enjoy the joke.” Twain apologized, and a few days later the two writers went on the bender that climaxed with them both airborne.

All this amusement proved ephemeral. Not only did such foolishness seem rather out of place once the Civil War had broken out, but it was as if a curse had fallen on the Pfaff bohemians. One by one, they died young, Whitman being one of the few exceptions — he lived to be 72. (Twain made it to 74, but he was only a Pfaffian once-removed.) By far the most important artistic contribution from the core group was “Leaves of Grass,” and between 1858 and ’62, when some of the poems were germinating, Whitman “was at the saloon virtually every night.”

This period in Whitman’s development is often skated over in biographies of the Good Gray Poet, and Martin has done us a favor by bringing it, along with a host of other artistic connections, amusingly and indelibly back to life.

Martin will be at Politics and Prose on Sept. 20 at 1 p.m.

Dennis Drabelle is a contributing editor of Book World. His books include “Mile-High Fever,” a history of the Comstock Lode.

REBEL SOULS

Walt Whitman and America’s First Bohemians

By Justin Martin

Da Capo. 339 pp. $27.99