Joe's naiveté becomes evident as quickly as his cash disappears upon his arrival in New York. He is hilariously, yet sadly, unsuccessful in his attempts to be hired as a "stud" for wealthy women. The naive Joe meets the crippled Enrico "Ratso" Rizzo (Dustin Hoffman), a third-rate con man who easily tricks Joe out of twenty dollars by offering to introduce him to a well-known pimp, who instead turns out to be a religious fanatic. Joe flees the scene in pursuit of Ratso, but he is long gone. As Joe's money quickly runs out, he finally attempts to make money by sleeping with another man, but even this plan goes awry. (The novel does refer to previous homosexual activity by Joe, but explains that he'd pursued it more in hopes to please a male friend than out of desire.)
Joe then spots an unsuspecting Rizzo at a diner. Joe has been homeless after being locked out of his hotel room for failure to pay the bill. He has been sleeping in all-night movie theaters and bus stations. Joe angrily shakes Ratso down for every penny he has, but Ratso surprisingly offers to help Joe, by sharing his "place"; an apartment in a condemned building. Joe reluctantly accepts the offer, and they begin a "business" relationship, helping each other pickpocket, steal and further attempt to get Joe hired as a "stud".
The events of Joe's life are told in mostly chronological order, interspersed by flashbacks. He had been to church and baptized as a boy, but had only frightening memories of the experience, and he related religion with disappointment. The only two people Joe loved were his grandmother Sally, and his onetime girlfriend "Crazy Annie" (called "Chalkline Annie" in the novel). His grandmother raised Joe after his mother abandoned him, but often left him alone to go off with boyfriends. (One of them, a wrangler named Woodsy Niles, was Joe's only father figure.) Sally died while Joe was away serving in the Army. Annie had been a promiscuous girl, who changed her ways after meeting Joe. This didn't sit well with the men of their hometown. After the two were caught together having sex in a car, the mob rapes both Annie and Joe Buck; later Annie was sent to a mental institution. She remains a constant presence in Joe's mind.
Ratso's story comes mostly through things he tells Joe. His father was an illiterate shoeshiner who worked in a subway station, developed a bad back, and "coughed his lungs out breathin' in that wax every day!" Ratso learned shining from his father, but refused to follow (such as he could, after polio crippled one leg) in the old man's footsteps.
Joe and Ratso also steal things as they need them, and pull minor scams like loading up on saltine crackers and ketchup at diners, and checking every coin slot they see for change. They are both completely alone without each other, and a genuine bond develops between the two men. Ratso had a cough when the two first met during the summer, and as the story progresses, his health steadily worsens. His symptoms indicate a likely case of tuberculosis, but Ratso refuses to see a doctor, professing he'll be fine "when I get to Florida!" In the meantime he consumes cough medicines.
At one point, a bizarre-looking couple approach Joe and Ratso in a diner and hand Joe a flyer inviting him to a party. The two men go together and enter into a Warhol-esque party scene (with some of the Warhol superstars in cameo appearances). The naive Joe smokes an entire marijuana joint thinking it was a cigarette, then takes a pill offered to him and begins to hallucinate. He leaves the party with a socialite (Vaccaro), who agrees to pay him $20 for one night with him. Ratso falls down a flight of stairs, but insists he is fine, and makes his own way home.
Joe and the socialite attempt sex, but he suffers from temporary impotence. After sleeping, they play a puzzle game together. She suggests that Joe may be gay, then continues to mildly tease him. Joe is suddenly able to perform, and the two have rough, enthusiastic sex.
When Joe returns home later, Ratso is in bed, sweating and feverish, and admits to Joe that he is unable to walk. Joe wants to take Ratso to a doctor, but Ratso adamantly refuses, saying he does not want to end up in Bellevue Hospital or someplace worse. He wants to leave New York for Miami; this has been his goal the whole time. Ratso is clearly gravely ill. A frightened Joe is determined to take care of his friend, and leaves the apartment.
Joe picks up an older male customer (Barnard Hughes), who tries to send him away at the last minute out of guilt. Joe is enraged when the customer gives him a religious medallion, instead of cash when Joe says he needs it. He beats and robs the man, stuffing the telephone receiver into his mouth when he tries to call for help. (It's unclear whether the man dies as a result of Joe's attack; in the next sequence, on the bus to Florida, Ratso asks Joe, "You didn't kill him, did you?" to which Joe replies, "I don't want to talk about it.")
With the money, Joe buys two bus tickets to Florida. Ratso's physical condition is clearly serious, and the point is driven home by a bus scene in which Ratso awakens to find he has urinated on himself. When he tells Joe, Joe makes a joke by saying, "You just took a little rest stop that wasn't on the schedule!" They laugh together, but their powerful denial is now evident. Joe stops to buy new clothing for Ratso and himself on the way. Joe throws away his cowboy outfit, and declares "I ain't no kinda hustler." As they reach Florida and near Miami, Joe talks about plans to get a regular job, only to ultimately realize that Ratso has died sitting beside him.
After Joe informs the bus driver, the driver tells him that there is nothing else to do, but leave him there until they arrive in Miami. The final scene is of a horrified Joe seated beside his dead friend, placing his arm around him, with several of the other passengers standing up and turning around in their seats to stare. He stares out the bus window and numbly watches row after row of palm trees go by.
The line "I'm walkin' here!", which reached #27 on AFI's 100 Years... 100 Movie Quotes, is often said to have been improvised, but producer Jerome Hellman disputes this account on the 2-disc DVD set of Midnight Cowboy. The cab was driven by a hired actor during a scripted take, and production team filmed it to look like an ad-lib. However, Hoffman told it differently on an installment of Bravo's Inside the Actors Studio. He stated that there were many takes to hit that traffic light just right so they didn't have to pause while walking. That take, the timing was perfect and the cab came out of nowhere and nearly hit them. Hoffman wanted to say "We're filming a movie here!" But from brain to mouth, it came out in the now famous line.
Before Dustin Hoffman auditioned for this film, he knew that his all-American image could easily cost him the job. To prove he could do it, he asked the auditioning film executive to meet him on a street corner in Manhattan, and in the meantime, dressed himself in filthy rags. The executive arrived at the appointed corner and waited, barely noticing the "beggar" less than ten feet away who was accosting people for spare change. At last, the beggar walked up to him and revealed his true identity.
Schlesinger chose the song "Everybody's Talkin'" (written by Fred Neil and performed by Harry Nilsson) as its theme, and the song reappears throughout the movie. (Other songs considered for the movie included Nilsson's own "I Guess the Lord Must Be in New York City", Randy Newman's "Cowboy", and reportedly Bob Dylan's "Lay Lady Lay".) The song "He Quit Me" was also on the soundtrack; it was written by Warren Zevon, who also included it (as "She Quit Me") on his debut album Wanted Dead or Alive. This film was Adam Holender's first cinematography assignment; he was recommended to Schlesinger by Holender's childhood friend, filmmaker Roman Polanski.
Late in 1970 United Artists had the film re-submitted to the ratings board in order to change the rating to R, increasing the number of screens it could play on in re-release, since many theaters would not play X-rated films, and many newspapers would not accept advertising for them.
Some modern critics assume an unstated homosexual relationship between the main characters, and at the 78th Academy Awards, host Jon Stewart joked about Brokeback Mountain being an Oscar contender despite its subject matter, saying "It's been more than 35 years when people would watch Midnight Cowboy and say 'What the hell was that all about?' Well, now we have fully accepted this new genre of cinema: gay westerns!"
The film won six BAFTA Awards.
The final scene with Joe's arms around Rizzo was parodied in the 1994 Seinfeld episode "The Mom & Pop Store": Jerry was the Joe Buck character comforting Kramer, who had a bloody nose. The theme song "Everybody's Talkin'" was played during this scene, and George at an earlier point sings it, improvising the line, "Just drivin' around in Jon Voight's car."
The movie Forrest Gump parodies the famous "I'm walking here!" line when Gump pushes Lieutenant Dan's wheelchair across a crowded Manhattan street.
An episode of American Dad! titled "Irregarding Steve" parodies the movie, with Roger the alien as the Rizzo character developing a steadily worsening cough after arriving in New York and Steve eventually donning a cowboy outfit similar to Joe's. The episode parodies several important scenes from Midnight Cowboy, including the final scene bus ride.
The 2006 film Apocalypto features a scene where sacrificial captives are being taken to the great Mayan city by a band of warriors. A group of lumberjacks cuts down a tree, nearly crushing the captives. The leader of the warriors, Zero Wolf, yells out, "I am walking here!"
The movie "Back to the Future 2" has the Michael J. Fox (playing his future son) coming out of the diner and almost being hit by a car, yelling "I'm walking here!" at the vehicle as it speeds away.
The Futurama episode "Brannigan Begin Again" a montage scene based on Midnight Cowboy. After the two characters Zapp Brannigan and Kif (as Joe and Ratso respectively) are discharged from the military, trying to survive in the world, including resorting to prostitution
In the video game Grand Theft Auto IV, Vlad is nearly hit by a taxi and he shouts out "Hey! I'm walking here!" during a cutscene.
In the comedy film Borat: Cultural Learnings of America for Make Benefit Glorious Nation of Kazakhstan, a montage of shots of Kazakhstani journalist Borat doing various inappropriate things on the streets of New York City is shown with the song "Everybody's Talkin'" played behind it.