The novel is focused on two locations (as suggested by the title): one, the early Beat Generation circle of New York in the late 1940s, the other, the nearly rural small town of Galloway, Massachusetts, that the main character comes from, before going off to college on a football scholarship.
Galloway represents the city of Lowell, Massachusetts, which the Merrimack river runs through, and where Kerouac was raised.
The experiences of the young "Peter Martin" struggling for success on the high school football team are largely those of Jack Kerouac (he returns to the subject again in his last work Vanity of Duluoz, published in 1968).
The "city" represents a number of figures of the early beat circle: Allen Ginsberg (as Leon Levinsky), Lucien Carr (as Kenneth Wood), William Burroughs (as Will Dennison), Herbert Huncke (as Junky), David Kammerer (as Waldo Meister), Edie Parker (as Judie Smith) and also Joan Vollmer (as Mary Dennison) – though she essentially has a non-speaking role (however some of her ideas are quoted by the Ginsberg-figure).
Near the end of the novel, the Waldo Meister character dies by falling from the window of Kenneth Wood's apartment (a distant echo of the real event: David Kammerer knifed by Lucien Carr, possibly in self-defense).
After reading sample chapters of The Town and the City (along with Kerouac's work-in-progress Dr. Sax), Mark Van Doren recommended the novel to Robert Giroux at Harcourt Brace in March 1949.
Giroux was impressed with the 1,100-page-long manuscript, which he thought comparable to Wolfe's Look Homeward, Angel in terms of its lyricism and poetry, and offered Kerouac a $1,000 advance against royalties.
Cutting and revising The Town and the City under the supervision of Giroux took months, according to Kerouac's friend John Clellon Holmes.
Giroux told Kerouac that movie producer David O. Selznick was interested in buying the rights to the book.
Kerouac made no more money on The Town and the City, as his royalties did not exceed his advance and a movie sale never materialized.