In 1925, in the Mexican oil-town of Tampico, Fred C. Dobbs and Bob Curtin, two unemployed American drifters, survive by bumming for spare change. They are recruited by an American labor contractor, Pat McCormick, as roughnecks to construct oil rigs for $8 a day. When the project is completed, McCormick skips out without paying the men.
Returning to Tampico, the two vagrants encounter the grizzled prospector Howard in a flophouse. The loquacious and penniless ex-miner holds forth on the virtues of gold prospecting and the perils of striking it rich. The two younger men feel the lure of gold and contemplate its risks. Dobbs and Curtin run into McCormick at a cantina, and after a desperate bar fight, they collect their back wages in cash. When Dobbs wins a small jackpot in the lottery, he pools his funds with Curtin and Howard to finance a gold prospecting journey to the Mexican interior.
Departing from Tampico by rail, the three help to repulse a bandit attack. Dobbs exchanges gunfire with his future nemesis, the Mexican outlaw leader Gold Hat. North of Durango the party is outfitted with gear and pack animals and begin their ascent into the remote Sierra Madre mountains. Howard proves to be the hardiest and most knowledgeable, outstripping the younger men in his physical endurance and wisdom. After several days of arduous travel, Howard’s keen eye recognizes that the terrain is laden with gold. He dances a jig to celebrate their good luck, to the dismay of his two comrades.
The men commence the exhausting process of extracting the riches, living and working in the harshest and primitive conditions. In time, they amass a fortune in placer gold. As the gold piles up, fear and suspicion take hold of each man. Dobbs is particularly susceptible and begins to lose his sanity to paranoia. The men agree to divide the gold dust so as to jealously conceal the whereabouts of their shares.
Curtin, while on a resupply trip to Durango, is spotted making purchases by a Texas fortune hunter named Cody. The Texan guesses the significance of Curtin’s aloofness, and trails him secretly back to the encampment. When he confronts them, the three claim holders tell the intruder they are merely hunters. Cody dismisses the lie, and boldly proposes to join their outfit to share in any future takings from the unregistered claim. Howard, Curtin and Dobbs, each more or less in thrall to the gold, hold a private counsel and vote to kill the newcomer. As they announce their verdict, pistols in hand, Gold Hat and his bandits arrive on the scene. They claim to be Federales and attempt to barter for firearms. After a tense vocal exchange regarding requested proof that the bandits are indeed Federales, a gunfight with the bandits ensues, in which Cody is killed. A genuine troop of Federales suddenly appears and pursues Gold Hat and his gang as they flee the encampment. The three prospectors examine the personal effects of the dead Cody. A letter he carries from a loving wife reveals that his motivations were to provide for his family.
Howard is called away to assist local villagers to save the life of a seriously ill little boy. When the boy recovers, the next day, the villagers insist that Howard return to the village to be honored and will not take no for an answer. Howard leaves his goods with Dobbs and Curtin and says he will meet them later. Dobbs, whose paranoia continues, and Curtin constantly argue, until one night when Curtin falls asleep, Dobbs holds him at gunpoint, takes him behind the camp, shoots him, grabs all three shares of the gold, and leaves him for dead. However, the wounded Curtin survives and manages to crawl away during the night.
Nearly dying of thirst, Dobbs is ambushed at a waterhole by Gold Hat and his accomplices. He attempts to shoot them, but finds that he has failed to reload his pistol after it was emptied by Curtin – allowing the bandits to brutally kill him. In their ignorance, they believe Dobbs’ bags of gold dust are merely filled with sand, and they scatter the precious metal to the winds, taking only his burros and supplies. Meanwhile, Curtin is discovered by indios and taken to Howard’s village, where he recovers.
Gold Hat’s gang try to sell the packing donkeys in town, but a child recognizes the branding mark on the donkeys (and Dobbs’ clothes, which the bandits are wearing) and reports them to the authorities. The bandits are captured and summarily executed by the Federales.
Howard and Curtin, arriving back in Durango in a dust storm, reclaim their pack animals, only to find the severed and empty gold sacks. At first shaken by the loss, Howard, then Curtin, grasp the immense irony of their circumstances, and they share in peals of laughter. They part ways, Howard returning to the indio village, where the natives have offered him a permanent home and position of honor, and Curtin returning home to the United States, where he will seek out Cody’s widow in the peach orchards of Texas.