The song was written during Lennon’s ‘Bed-In’ honeymoon in Montreal, Quebec, Canada. When asked by a reporter what he was trying to achieve by staying in bed, Lennon answered spontaneously, “Just give peace a chance.” He went on to say this several times during the Bed-In. Finally, on 1 June 1969, in Room 1742 at the Queen Elizabeth Hotel in Montreal, André Perry recorded it using a simple setup of four microphones and a four-track tape recorder rented from a local recording studio. The recording session was attended by dozens of journalists and various celebrities, including Timothy Leary, Rabbi Abraham Feinberg, Joseph Schwartz, Rosemary Woodruff Leary, Petula Clark, Dick Gregory, Allen Ginsberg, Roger Scott, Murray the K, and Derek Taylor, many of whom are mentioned in the lyrics. Lennon played acoustic guitar and was joined by Tommy Smothers of the Smothers Brothers, also on acoustic guitar.
When released in 1969, the song was credited to Lennon–McCartney. On some later releases, only Lennon is credited; viz. the 1990s reissue of the album Live in New York City, the 2006 documentary The U.S. vs. John Lennon, and the 1997 compilation album Lennon Legend: The Very Best of John Lennon and its DVD version six years later. Lennon later stated his regrets about being “guilty enough to give McCartney credit as co-writer on my first independent single instead of giving it to Yoko, who had actually written it with me.” However, it has also been suggested that the credit was a way of thanking McCartney for helping him record, “The Ballad of John and Yoko,” at short notice.