John Schlesinger's Midnight Cowboy won three Academy Awards, including Best Picture and Best Director, despite being controversial enough to earn an X-rating on its release May 25, 1969. It played an important role in music history, too.

Based on a 1965 novel of the same name by James Leo Herlihy, Midnight Cowboy depicted the friendship between Jon Voight's Joe Buck, a would-be hustler who has just arrived in New York City, and Enrico Salvatore "Ratso" Rizzo, a con artist with a limp played by Dustin Hoffman.

Buck's attempts to sell sex do not attract many buyers. He bonds with Rizzo, who invites Buck to share his apartment in an abandoned building. As Rizzo's health deteriorates, he asks Buck to help him on a doomed bus ride to Florida.

These scenes were set in a then-unusual way: Harry Nilsson's update of "Everybody's Talkin" soundtracks the film's opening. Rockers had, of course, long performed their songs in movies, but Midnight Cowboy was one of the earliest to include pop tunes as background music.

The soundtrack also includes two tracks from Elephant's Memory, who later collaborated extensively with John Lennon; Leslie Miller singing a tune by the then-unknown Warren Zevon; the Groop, a Californian band; and other songs from composer and musical supervisor John Barry.

Listen to Harry Nilsson Cover of 'Everybody's Talkin"

"Midnight Cowboy is still shown at UCLA Film School as the best example of song in film," Barry told Paul Tonks in 1997. "We didn’t go out and buy a bunch of songs. It was all written especially for the scenes. It was literally scoring with songs and [we] took a lot of care with it."

The outlier was Nilsson's take on "Everybody's Talkin'." Already a year old, the song initially stalled out at No. 113. So Nilsson decided to submit a similar-sounding original called "I Guess the Lord Must Be in New York City." "I tried to get as close to 'Everybody's Talkin" without pinching it, you know. Tried to get as close to the feel as I could," Nilsson later admitted. "It was about a guy in Texas looking for a better life in New York who meets a guy who is looking for a better life in Florida. It’s always over the next fence, or around the next corner. To me, that’s what it was about.”

Still, the producers ultimately preferred Nilsson's earlier take on "Everybody's Talkin'," a song by the obscure folksinger Fred Neil that was actually written in just five minutes during a 1966 session in Los Angeles. Anxious to return home to Miami but still short of material to complete an album, Neil banged out the tune in the bathroom. “He sang it once,” Neil's manager, Herb Cohen, told the New York Times in 2006, “and then we packed up, and I took him to the airport.”

Listen to Fred Neil's Original Version of 'Everybody's Talkin"

Fred Neil's lyric – "I'm going where the sun keeps shining through the pouring rain" – was a reference to his Florida home, and it meshed perfectly with the Midnight Cowboy script a few years later. Nilsson re-recorded "Everybody's Talkin'" for the soundtrack, and the film's popularity sent his song to No. 6 on the Billboard Hot 100 chart when it was re-released as a single in 1969.

Elephant's Memory contributed "Jungle Gym at the Zoo" and "Old Man Willow," the latter of which accompanies a drug-fueled party where a desperate Rizzo attempts to swipe some food. "The scene where he steals bread and is spotted and is shamed just kills you," Barry told Paul Tonks. "The loneliness of that song drifting down over it had such an atmosphere I couldn't have got with a score. If it’s done right it can be terribly effective. That was John [Schlesinger]'s choice and I learned a lot from it. We spent four or five hours re-recording to film."

Miller was already a popular TV commercial and background singer when she covered "He Quit Me" for the film's soundtrack. Unfortunately, she didn't get a Nilsson-esque career bump out of Midnight Cowboy, so Miller – who also went by Lesley – returned to her original gig. She later recorded backing vocals on Steely Dan's Gaucho and Donald Fagen's The Nightfly LPs, among others.

Listen to the Main Theme from 'Midnight Cowboy'

Filmmaking, on the other hand, was never quite the same again, as pop songs came to dominate soundtracks. "It has changed a lot insofar as the role of popular music has increased greatly," Barry told Martin Crosthwaite in 1979. "That is the most significant external influence – and some of it is good, as in Midnight Cowboy. In that situation, I thought it was an excellent integration of pop music of the day. That atmosphere, using songs to score dramatically was good and worked well."

Already famous for his work on James Bond films dating back to 1962's Dr. No, Barry claimed a 1969 Grammy for the Midnight Cowboy instrumental theme. His score featured jazz musician Toots Thielemans, whose chromatic harmonica gave the movie a melancholy feel that mirrored the characters' lives. Tommy Reilly re-recorded the harmonica tracks for the soundtrack album. Ferrante & Teicher's version was a Top 10 hit on the Billboard Hot 100.

For all of that success, the Midnight Cowboy soundtrack actually could have been better. Bob Dylan was also commissioned to write a song for the film. He began work on "Lay Lady Lay" but was unable to finish in time. Released later in 1969 on Nashville Skyline, the song became a No. 7 Billboard hit.

See Harry Nilsson Among the Top 200 '70s Rock Songs