The novel was based on Hemingway's own experiences serving in the Italian campaigns during the First World War. The inspiration for Catherine Barkley was Agnes von Kurowsky, a nurse who cared for Hemingway in a hospital in Milan after he had been wounded. He had planned to marry her but she spurned his love when he returned to America. Kitty Cannell, a Paris-based fashion correspondent, became Helen Ferguson. The unnamed priest was based on Don Giuseppe Bianchi, the priest of the 69th and 70th regiments of the Brigata Ancona. Although the sources for Rinaldi are unknown, the character had already appeared in In Our Time.
Much of the plot was written in correspondence with Frederic J. Agate. Agate, Hemingway’s friend, had a collection of letters to his wife from his time in Italy, which were later used as inspiration.
Michael Reynolds, however, writes that Hemingway was not involved in the battles described. Because his previous novel, The Sun Also Rises, had been written as a roman à clef, readers assumed A Farewell to Arms to be autobiographical. A Farewell to Arms was begun during his time at Willis M. Spear's guest ranch in Wyoming's Bighorns. Some pieces of the novel were written in Piggott, Arkansas, at the home of his then wife Pauline Pfeiffer, and in Mission Hills, Kansas while she was awaiting delivery of their baby. Pauline underwent a caesarean section as Hemingway was writing the scene about Catherine Barkley's childbirth.
The novel was first serialized in Scribner's Magazine in the May 1929 to October 1929 issues. The book was published in September 1929 with a first edition print-run of approximately 31,000 copies. The success of A Farewell to Arms made Hemingway financially independent.
The Hemingway Library Edition was released in July 2012, with a dust jacket facsimile of the first edition. The newly published edition presents an appendix with the many alternate endings Hemingway wrote for the novel in addition to pieces from early draft manuscripts.
The JFK Library Hemingway collection has two handwritten pages with possible titles for the book. Most of the titles come from The Oxford Book of English Verse. One of the possible titles Hemingway considered was In Another Country and Besides. This comes from The Jew of Malta by Christopher Marlowe. The poem Portrait of a Lady by T. S. Eliot also starts off by quoting this Marlowe work: "Thou hast committed/ Fornication: but that was in another country,/ And besides, the wench is dead." Hemingway's library included both works by Eliot and Marlowe.
There are at least two copies of the first edition in which Hemingway re-inserted the censored text by hand, so as to provide a corrected text. One of these copies was presented to Maurice Coindreau; the other, to James Joyce. Hemingway's corrected text has not been incorporated into modern published editions of the novel; however, there are some audiobook versions that are uncensored.
Also, the novel could not be published in Italy until 1948 because the Fascist regime considered it detrimental to the honor of the Armed Forces, both in its description of the Battle of Caporetto, and for a certain anti-militarism implied in the work. More than one biographer suggests that at the base of the censorship of the Fascist regime in the novel there had also been a personal antipathy between the writer and Benito Mussolini. Hemingway had interviewed him in 1923, shortly after he seized power, and in his article in the Toronto Star he poured scorn on Mussolini, calling him "the biggest bluff in Europe." But, apart from the official reactions, it is known that Mussolini did not like the article at all: Hemingway described Mussolini as trying to impress the media by pretending to be deeply absorbed in reading, while in reality holding a French-English dictionary–held upside down. The Italian translation had in fact already been prepared illegally in 1943 by Fernanda Pivano, leading to her arrest in Turin.