The ancestries of the modern guitar, like numerous other chordophones, track back through many instruments and thousands of years to ancient central Asia. Guitar like instruments appear in ancient carvings and statues recovered from the old Persian capital of Susa. This means that the contemporary Iranian instruments such as the tanbur and setar are distantly related to the European guitar, as they all derive ultimately from the same ancient origins, but by very different historical routes and influences.
During the Middle Ages, instruments called "guitars" with three and four strings were in use but their construction and tuning was different from the modern guitars. The Guitarra Latina in Spain, had curved sides and a single hole. The Guitarra Morisca, which was brought to Spain by the Moors or at least was heavily influenced by Moorish instruments, had an oval soundbox and many sound holes on its soundboard. By the 15th century, a four course double-string instrument called the vihuela de mano, that had tuning like the later modern guitar except on one string and similar construction, appeared in Spain and spread to Italy; by the 16th century, a fifth double-string had been added. During this time, composers wrote mostly in tablature notation. In the middle of the 16th century, influences from the vihuela and the renaissance guitar were combined and the baroque five string guitar appeared in Spain. The baroque guitar quickly superseded the vihuela in popularity in Spain, France and Italy and Italian players and composers became prominent. In the late 18th century the six string guitar quickly became popular at the expense of the five string guitars. During the 19th century the Spanish luthier and player Antonio de Torres gave the modern classical guitar its definitive form, with a broadened body, increased waist curve, thinned belly, improved internal bracing, single string courses replacing double courses, and a machined head replacing wooden tuning pegs. The modern classical guitar replaced older form for the accompaniment of song and dance called flamenco, and a modified version, known as the flamenco guitar, was created.