San Pedro was a pre-Columbian pit stop on the trading route from the highlands to the coast. It was visited by conquistador Pedro de Valdivia in 1540, and the town later became a major stop on early 20th-century cattle drives from Argentina to the nitrate oficinas of the desert.

Locals, the Atacameño people, still practice irrigated farming in the ayllus (a-ee-oos; small indigenous communities). Many farm on terraces over a thousand years old.