J.P. Donleavy’s 1955 debut established him as one of the funniest writers in the England language. (Graham Harrison/Rex Features via AP)

J.P. Donleavy, an Irish American novelist whose 1955 debut, “The Ginger Man,” was rejected by 45 publishers for its scabrous, sexually explicit content but eventually sold more than 45 million copies and came to be regarded as a modern classic, died Sept. 11 at a hospital near his home in Mullingar, County Westmeath. He was 91.

A sister, Mary Rita Donleavy, told the New York Times he died after a stroke.

Mr. Donleavy was a New York native who moved to Ireland for college, adopted an outfit of corduroy and tweed (along with a matching brogue) and established himself as an itinerant successor to James Joyce. He wrote more than a dozen novels and story collections, many of them set in Dublin, and was sometimes described as one of the funniest — and finest — writers in the English language.

“No contemporary writer is better than J.P. Donleavy at his best,” the New Yorker wrote in a review of “Meet My Maker the Mad Molecule,” a 1964 collection with an alliterative title that became a feature in books such as “The Saddest Summer of Samuel S” (1966), “The Beastly Beatitudes of Balthazar B” (1968), and “The Destinies of Darcy Dancer, Gentleman” (1977).

Yet Mr. Donleavy’s literary reputation rested almost entirely on his first novel. “The Ginger Man” was a semiautobiographical account of red-bearded Sebastian Dangerfield, an impoverished American World War II vet who studies at Trinity College, exposes himself on the trolley and strays far from his wife, Marion.

The novel’s bawdy descriptions nearly prevented it from being published. Rather than cut the salacious bits, which in Mr. Donleavy’s opinion contained the core of the book, he followed the suggestion of Irish poet Brendan Behan and submitted the novel to Olympia Press in Paris.

The publishing house would later release Vladi­mir Nabokov’s “Lolita.” At the time, however, it was launching a series of potentially lucrative pornographic novels under the name Traveler’s Companion, and scooped up Mr. Donleavy’s book alongside titles such as “White Thighs” and “School for Sin.”

“When I discovered that the novel was published in this pornographic series, I realized I would never have any reputation, that the book would never exist in any real form — it was just a piece of pornography,” he told Britain’s Guardian newspaper in 2004. “It wouldn’t get any reviews. It was a total nightmare.”

Still, an abridged version of the book began to gain traction in England, and Mr. Donleavy found his revenge against Olympia in a two-decade-long legal war over the rights to his novel. (He prevailed and eventually acquired a bankrupt Olympia at auction, through a holding company called the Little Someone Corp.).

Mr. Donleavy’s book employed an experimental style, with shifting points of view and staccato sentences: “Sebastian went looking for aspirin. The house looks unusually empty. The closet. Marion’s clothes are gone. Just my broken rubbers on the floor. The nursery. Cleaned out. Bare. Take that white cold hand off my heart.”

But the book eventually landed at No. 99 on the Modern Library’s list of the best novels, just ahead of Booth Tarkington’s “The Magnificent Ambersons.” A theatrical adaptation starring Richard Harris opened in London in 1959 before moving to Dublin, where opposition from critics and the Catholic church led it to close after just three performances. A television adaptation aired on the BBC in 1962.

A long-sought film version of the book never transpired, but Mr. Donleavy leveraged his book sales into a new life of leisure, spending decades on a 180-acre, 18th-century manor west of Dublin, where he raised cattle, swam in his indoor pool, and regaled visitors with stories of how a young James Joyce once slept in the house as a child.

“Money is everything in my profession,” he told the Paris Review in 1975, settling into his newfound financial security. “One’s mind almost becomes a vast cash register. . . . To sit at a desk and think, and write, you must have peace, and to buy peace costs a fortune.”

James Patrick Donleavy was born in Brooklyn on April 23, 1926, and raised in the Bronx, where he took up boxing as a child. His parents were Irish immigrants, and his father worked for the city fire department.

Mr. Donleavy served in the Navy during World War II before moving to Dublin, where he studied zoology at Trinity College and frequently found himself in the middle of bar fights; his appearance as a bearded Yankee “narrowback,” he said, likely caused a few of the brawls, which included fights with Behan.

Mr. Donleavy also became an accomplished painter and was exhibited in Dublin three times before he took a set of canvases to London and was told he wasn’t famous enough to be exhibited.

“I realized that the only way you could ever tackle the world was to write something that no one could hold off, a book that would go everywhere, into everyone’s hands,” he told the Paris Review. “And I decided then to write a novel that would shake the world. I shook my fist and said I would do it.”

Mr. Donleavy’s idiosyncratic style continued in his later books, which often featured chapters that ended with short poems and misspellings such as “limozine.” His legal fights also persisted: His second novel, “A Singular Man” (1963) — fittingly about a man facing a barrage of legal threats — was published only after he threatened to sue Atlantic Monthly Press, which had avoided publishing the novel over concerns about its sexual content.

Some critics accused him of recycling his picaresque plots and ideas, which at times seemed to verge on the nihilistic. Mr. Donleavy, however, seemed to have never lost his sense of humor; in 1975, he published a satirical guide to manners, “The Unexpurgated Code,” that advised readers on how best to deal with “being excluded from Who’s Who” and how to change their names to win new friends.

His first marriage, to Valerie Heron, ended in divorce in 1969. He married Mary Wilson Price, an actress, the following year, and they divorced in 1989. Mr. Donleavy had two children from his first marriage, Philip and Karen, and two children from his second marriage, Rebecca and Rory.

In 2011, it was reported that Mr. Donleavy had not fathered his two children with Price. A DNA test in the early 1990s had confirmed that Rebecca was the daughter of brewing scion Kieran Guinness, and Rory was the son of Kieran’s older brother Finn, whom Price married after her divorce with Mr. Donleavy.

“My interest is only to look after the welfare of the child,” Mr. Donleavy told the Times, “and after a certain stage, you can’t worry about their parentage.”