All the Pretty Horses begins with the 1949 funeral of John Grady Cole's grandfather. With his death, John Grady's mother will sell their Texas ranch and move away. There is nothing left in Texas for John Grady, who loves the ranch and idealizes the cowboy's way of life. Only sixteen years old, John Grady runs away from home with his friend Rawlins. On horseback, they head toward the Mexican border, leading the idyllic, storybook life of migrant cowboys. They are joined by a younger boy, the sensitive and stubborn Jimmy Blevins. Together, the three cross over the Rio Grande into Mexico.
Soon after they enter Mexico, the companions ride into a lightning storm. Blevins, who is terrified of lightening, strips off his clothes, abandons his horse, and hides in a ditch. The next day finds him nearly naked, his horse and gun stolen. In the village of Encantada, the companions see Blevins' lost horse, but it has been claimed by someone else. In the aftermath of their attempt to steal the horse back, Rawlins and Cole become separated from Blevins. They escape from the posse pursuing them, however, and continue to travel south, where they find work as cowboys on the vast ranch owned by Don Hector.
John Grady quickly proves himself a remarkable cowboy with an intuitive understanding of horses. Don Hector, impressed, puts him in charge of breeding the ranch's horses. But John Grady's good fortune is imperiled by his infatuation with Don Hector's beautiful daughter, Alejandra. Although John Grady is warned off by Alfonsa, Alejandra's cynical and manipulative great-aunt, he nevertheless falls in love with the girl, and they begin an illicit affair. When Don Hector finds out about it, he turns John Grady and Rawlins over to the thuggish, corrupt police captain of Encantada. Blevins, it seems, returned to Encantada to reclaim his gun and killed at least one of the townspeople. Now he is being held in jail, and John Grady and Rawlins are accused of being his co- conspirators. Rawlins is tortured until he gives a false confession.
Blevins is executed, but John Grady and Rawlins are merely imprisoned in the town of Saltillo. In the prison the Americans are marked as victims, and forced to fight constantly to survive. When they refuse to ally themselves with the wealthy, influential prisoner Perez, he sends assassins after them both. Both men survive the attacks--with John Grady killing his assailant--but they are badly wounded, and end up in the hospital's infirmary. Only partially recovered, they are suddenly released by the prison commander, who has been bribed by Alfonsa at Alejandra's request.
Although Rawlins returns to Texas, John Grady is intent on reuniting with Alejandra. He goes back to the ranch, where Alfonsa meets with him, delivering a long discourse about human powerlessness and about the foolishness of romantic dreams. Nevertheless, he meets with Alejandra and they spend a short day together, but in the end she decides that she cannot abandon her family for him.
John Grady, shattered, refuses to leave Mexico without his horses. He goes back to Encantada and, taking the captain as a hostage, reclaims the American horses. He is pursued on the way back and wounded severely, but manages to evade the pursuit and cross back into Texas. He finds that he no longer has a home: his father is dead, the ranch sold, and his friend Rawlins seems like a stranger. The novel ends with John Grady riding west, into the setting sun.