In the pre-Columbian period the territory was dominated by diverse indigenous groups as arawacs, tupis and guaranies. With the passage of time the groups who controlled the territory were known as cholones and hibitos until the evangelism and set of laws took place by the Franciscans in the 17th century.The founder of the city is Jose Gaspar Lopez Salcedo, a Spanish who arrived to Peru in 1817 and fought for the realist cause without success, reason why he decided to remake his life in Lamas. He was told about a place with abundant resources, so he began the travel to Chacho and in 1826 with the support of the settlers they decided to enlarge the territory they occuppied. In December the 24th 1827 was founded the town, the Virgen de las Mercedes date, and the name of Juanjui is in honor of Juan Huido, an indian who emigrate to the area in previous times.