The novel Fear and Loathing in Las Vegas is based on two trips to Las Vegas, Nevada, that Hunter S. Thompson took with attorney and Chicano activist Oscar Zeta Acosta in March and April 1971. The first trip spawned from an exposé Thompson was writing for Rolling Stone magazine about the Mexican-American television journalist Rubén Salazar, whom officers of the Los Angeles County Sheriff's Department had shot and killed with a tear gas grenade fired at close range during the National Chicano Moratorium March against the Vietnam War in 1970. Thompson was using Acosta—a prominent Mexican-American political activist and attorney—as a central source for the story, and the two found it difficult for a brown-skinned Mexican to talk openly with a white reporter in the racially tense atmosphere of Los Angeles, California. The two needed a more comfortable place to discuss the story and decided to take advantage of a Sports Illustrated magazine offer to write photograph captions for the annual Mint 400 desert race being held in Las Vegas from 21–23 March.
Thompson wrote that he concluded their March trip by spending some 36 hours alone in a hotel room "feverishly writing in my notebook" about his experiences. The genesis of Fear and Loathing in Las Vegas: A Savage Journey to the Heart of the American Dream is in that notebook.
What originally was a two-hundred-fifty-word photo-caption-job for Sports Illustrated grew to a novel-length feature story for Rolling Stone; Thompson said publisher Jann Wenner had "liked the first 20 or so jangled pages enough to take it seriously on its own terms and tentatively scheduled it for publication — which gave me the push I needed to keep working on it". He had first submitted a 2,500-word manuscript to Sports Illustrated that was "aggressively rejected".
Weeks later, Thompson and Acosta returned to Las Vegas to report for Rolling Stone on the National District Attorneys Association's Conference on Narcotics and Dangerous Drugs being held from 25–29 April 1971, and to add material to the larger Fear and Loathing narrative. Besides attending the attorneys' conference, Thompson and Acosta looked for ways in Vegas to explore the theme of the American Dream, which was the basis for the novel's second half, to which Thompson referred at the time as "Vegas II".
On 29 April 1971, Thompson began writing the full manuscript in a hotel room in Arcadia, California, in his spare time while completing "Strange Rumblings in Aztlan", the article chronicling the death of Salazar. Thompson joined the array of Vegas experiences within what he called "an essentially fictional framework" that described a singular free-wheeling trip to Vegas peppered with creative licenses.
In November 1971, Rolling Stone published the combined texts of the trips as Fear and Loathing in Las Vegas: A Savage Journey to the Heart of the American Dream as a two-part article illustrated by Ralph Steadman, who, two years before, had worked with Thompson on a Scanlan's Monthly article titled "The Kentucky Derby Is Decadent and Depraved". Random House published the hardcover edition in July 1972, with additional Steadman illustrations; The New York Times said it is "by far the best book yet on the decade of dope", with Tom Wolfe describing it as a "scorching epochal sensation".