The making of of a sauce by combining chiles, tomatoes and other ingredients like squash seeds and even beans has been documented back to the Aztec culture.
We have Spanish-born Bernadino de Sahagun to thank for the detailed culinary history of the Aztec culture. His extensive writings documented every food common to the culture. This is an excerpt from Sahagun's writings about the food vendors in the large Aztec markets:
"He sells foods, sauces, hot sauces, fried [food], olla-cooked, juices, sauces of juices, shredded [food] with chile, with squash seeds, with tomatoes, with smoke chile, with hot chile, with yellow chile, with mild red chile sauce, yellow chile sauce, sauce of smoked chile, heated sauce, he sells toasted beans, cooked beans, mushroom sauce, sauce of small squash, sauce of large tomatoes, sauce of ordinary tomatoes, sauce of various kinds of sour herbs, avocado sauce. (Sahagun, translated 1950 -1982).
The paragraph above refers to many of the ingredients in our modern-day salsas.