Dylan's connection to the project deepened when Rudy Wurlitzer, the film's screenwriter, asked him for some songs. After portraying "Billy" for director Peckinpah, who was moved, Dylan was offered a role. Filming took place in Durango, Mexico, where Dylan and his family moved in November 1972, and continued until early 1973. The first recording sessions for the soundtrack occurred in January 1973 at CBS Discos Studios in Mexico City. From that session, "Billy 7" was included on the final album, along with several takes of "Billy" and other tracks that were left out, such as "Under Turkey" and "Billy Surrenders". A month later, at Burbank Studios, California, the rest of the album's songs were recorded, in addition to pieces like "Sweet Amarillo" and "Rock Me, Mama". Of the 24 compositions Bob Dylan recorded for the project, only ten made it onto the official album.
Despite the initial critical reception, which some deemed unfavorable, with comments pointing to amateur quality or a deliberate attempt to deviate from commercial expectations, the album left an indelible mark. Tracks like Knockin' on Heaven's Door proved incredibly influential, being covered by artists such as Eric Clapton and Guns N' Roses. Furthermore, songs like "Rock Me, Mama" and "Sweet Amarillo" inspired other musicians, with Old Crow Medicine Show crediting Bob Dylan as a co-writer on their own later versions.