The movie takes place in 1913, during the height of the Mexican Revolution. In the fictional town of San Rafael, Texas (a fictional town named after the military academy in California Peckinpah attended as a teenager), also referred to as Starbuck, the Wild Bunch - led by Pike Bishop (Holden), and also including Dutch Engstrom (Borgnine), Lyle and Tector Gorch (Oates and Johnson), Angel (Sanchez), Buck (Rayford Barnes), and Crazy Lee (Hopkins), among others - enters the town, with half of them dressed as United States cavalry soldiers. They ride past a group of children who are torturing a pair of scorpions by putting them on a hill of red ants (this image was suggested by Emilio Fernandez; he said that he and his friends had done similar things as children), a very symbolic image which symbolizes the events of the film. The gang breaks into the bank and holds it up, but on the roof of a hotel across the street is a ragtag posse of bounty hunters, led by Patrick Harrigan (Albert Dekker), a railroad detective, and Deke Thornton (Ryan), a former member of the gang being ambushed, along with scruffy bounty hunters Coffer (Martin), T.C. (Jones), Huey (Paul Harper), and Jess (stuntman Bill Hart).
The gang's escape is interrupted by the local temperance union, which is holding a parade in the town, led by Reverend Wainscoat (Taylor), playing "Shall We Gather At The River?" (a hymn used as a funeral song in innumerable John Ford Westerns, used here for ironic effect). Various members of the gang, inside and out of the bank, spot the bounty hunters and Pike uses a bank teller as a decoy, throwing him out of the bank to draw the fire of the bounty hunters, allowing for the gang's escape.
A vicious, confusing gunfight occurs, with gang members, bounty hunters, and civilians caught in the crossfires, resulting in numerous deaths. Only six members of the gang escape - Pike, Dutch, the Gorches, Angel, and Buck, who has been shot in the face and blinded - and the rest of the gang is killed. Crazy Lee is left behind to hold the bank patrons as hostages; when Harrigan and Thornton's gang descend from the roof of the hotel to scavenge from the various dead bodies, he is ultimately killed by Harrigan. Outside of town, Pike executes Buck, who is unable to continue riding due to his injuries.
The surviving gang members arrive at a small Mexican town, where another gang member, the old Freddie Sykes (O'Brien), is waiting with horses and saddles. In this scene, they realize that the robbery was a set-up by the railroad - all of their earnings have been nothing but bags of steel washers. The excitable Gorches very nearly turn on Angel and Sykes, but they are held in check by Pike and Dutch. Later in the film, Sykes reveals to Pike that Crazy Lee - who had been deliberately left behind by Pike - was his grandson.
We also learn as the film progresses that Thornton has been given his parole in exchange for his tracking down his old colleague Pike. Though Thornton continually disparages his posse as "gutter trash", he reluctantly continues his pursuit of the gang throughout the film. Pike reveals through flashback (most of which were cut by the studio in the original version) how he abandoned Thornton to the railroad detectives, and also how he developed his painful leg wound (he had an affair with a Mexican woman, played by Aurora Clavell, and was shot by her husband) which he suffers from throughout the film.
Pike and his men return to Angel's village and remain there for a day and night. Pike learns from the village elder, Don Jose (Chano Urueta) that the village has been attacked by General Mapache (Fernandez), a Mexican general working for the government of General Huerta. Angel's father was hanged, and his girlfriend taken by Mapache for his own. Though he tells Pike that he will not avenge his father, Angel remains obsessed with getting his vengeance on Mapache throughout the film.
The gang then heads to Agua Verde, Mapache's headquarters, to trade their horses. As they go to visit the General, Angel sees Teresa, his girlfriend, presenting a pony to Mapache. Angel shoots her in the arms of Mapache, nearly leading to a confrontation between the Mexicans and the gang, but Pike and Dutch diffuse it. They are later hired by Mapache and his German military advisers to steal a US arms shipment for him, which they agree to for a price of ten thousand dollars - but Angel insists that they allow him to take a case of rifles to his village to protect them from Mapache. Pike and Dutch agree.
The Bunch holds up the train and kills the soldiers guarding the weapons, but Thornton and his posse are also on board the train and pursues them to a bridge over the Rio Grande, themselves being pursued by a squad of inept cavalrymen. After a confusing three-way shootout, the Bunch recrosses the border into Mexico. Thornton and his men are blown into the river when the dynamite wired to the bridge explodes, and the gang makes their escape. After getting themselves back together, Thornton and his men pursue the gang into Mexico.
Out on the trail toward Agua Verde, the Bunch are met by a small group of Pancho Villa's men -- Angel had convinced his comrades to give one of the sixteen cases of rifles to these men to use in their fight against Mapache and Huerta. Angel's Mexican comrades silently sneak up on the Bunch after dark and hold them hostage for a few minutes until Angel can square things. Pike and Dutch seem quite impressed with the ability of the revolutionaries to get the drop on them, however the Gorches are angry that they'd been made to look like fools. The Mexicans leave as silently as they arrived.
While waiting for word of the Bunch's robbery at a telegraph station, Mapache and his entourage are attacked by forces led by Pancho Villa and routed. Mapache sends one of his subordinates, Captain Herrera (Alfonso Arau), to meet the Bunch in a ravine with a large group of soldiers, but the confrontation nearly turns violent after a nervous Mexican soldier fires at the wagon holding the weapons. The Bunch has wired the wagon with dynamite, and Pike lights the fuse until Herrera diffuses the situation by executing the soldier who has fired on the gang. The Bunch then elaborately hides their weapons haul - fifteen cases of rifles, plus a Browning M1917 machine gun - and gives it in installments to Mapache in exchange for their money. Unfortunately, when Angel and Dutch arrive in town, Mapache reveals that he has been tipped off by Teresa's father of Angel's perfidy -- for killing his daughter, the father revealed to Mapache that one of the cases of rifles was given to the rebels by Angel. Angel is captured by Mapache's men, and Dutch simply rides off.
The gang regroups at a canyon outside of town, waiting for Sykes to return with their packhorses, and they argue over what to do. Then they watch as Sykes is ambushed and seriously wounded by Thornton's posse. Pike decides to abandon his old friend, who is being pursued hotly by Thornton's men, and return to Agua Verde to retrieve Angel. Mapache refuses to turn over Angel, who has been badly tortured, and invites the gang to spend the night in town whoring and drinking.
The next morning, Pike decides to make a stand. The four gang members load up shotguns, rifles, and sidearms and march through Agua Verde to Mapache's headquarters. After demanding Angel's release again, a drunken Mapache slits Angel's throat, and he is subsequently gunned down by Pike and Dutch. After a tense moment, where the drunken soldiers under Mapache react, unsure of what to do, Pike takes deliberate aim at Captain Mohr, Mapache's adviser, and shoots him.
A vicious, bloody gunfight (referred to as the "Battle of the Bloody Porch" by the film's crew) results as the Bunch shoots their way through Mapache's officers and seizes the machine gun. They inflict scores of casualties on the Mexicans but finally fall due to the sheer number of their foe. Lyle and Tector are shot repeatedly as they try to man the machine gun; Pike is finally killed by a Mexican boy who shoots him in the back; Dutch is gunned down rushing to his side.
After the battle, Thornton and his surviving men ride into town and begin looting the bodies of the Mexican soldiers and their prey, while Thornton looks at his fallen colleagues in pity, taking Pike's unused revolver. Thornton declines to join the bounty hunters as they return to the United States, remaining at Agua Verde; they are ambushed and killed somewhere down the trail. Sykes, Don Jose, and a large group of Villistas later arrive at the town, and Thornton decides to join them.