The name "guitar" comes from the ancient Sanskrit word for "string" - "tar". (This is the language from which the languages of central Asia and northern India developed.) Many stringed folk instruments exist in Central Asia to this day which have been used in almost unchanged form for several thousand years, as shown by archeological finds in the area. Many have names that end in "tar", with a prefix indicating the number of strings for example:
two = Sanskrit "dvi" - modern Persian "do" -
dotar: two-string instrument found in Turkestan
three = Sanskrit "tri" - modern Persian "se" -
setar: 3-string instrument, found in Persia (Iran),
(cf. sitar, India, elaborately developed, many-stringed)
four = Sanskrit "chatur" - modern Persian "char" -
chartar, 4-string instrument, Persia (most commonly known as "tar" in modern usage)
(cf. quitarra, early Spanish 4-string guitar, modern Arabic qithara, Italian chitarra, etc)
The Indian sitar almost certainly took its name from the Persian setar, but over the centuries the Indians developed it into a completely new instrument, following their own aesthetic and cultural ideals.
The guitar's ancestors came to Europe from Egypt and Mesopotamia. These early instruments had, most often, four strings - as we have seen above, the word "guitar" is derived from the Old Persian "chartar", which, in direct translation, means "four strings". Many such instruments, and variations with from three to five strings, can be seen in mediaeval illustrated manuscripts, and carved in stone in churches and cathedrals, from Roman times through till the Middle Ages.
By the beginning of the Renaissance, the four-course (4 unison-tuned pairs of strings) guitar had become dominant, at least in most of Europe. The earliest known music for the four-course "chitarra" was written in 16th century Spain. The five-course guitarra battente first appeared in Italy at around the same time, and gradually replaced the four-course instrument. The standard tuning had already settled at A, D, G, B, E, like the top five strings of the modern guitar.
In common with lutes, early guitars seldom had necks with more than 8 frets free of the body, but as the guitar evolved, this increased first to 10 and then to 12 frets to the body.
A sixth course of strings was added to the Italian "guitarra battente" in the 17th century, and guitar makers all over Europe followed the trend. The six-course arrangement gradually gave way to six single strings, and again it seems that the Italians were the driving force.
In the transition from five courses to six single strings, it seems that at least some existing five-course instruments were modified to the new stringing pattern. This was a fairly simple task, as it only entailed replacing (or re-working) the nut and bridge, and plugging four of the tuning peg holes.
At the beginning of the 19th century one can see the modern guitar beginning to take shape. Bodies were still fairly small and narrow-waisted.
The modern "classical" guitar took its present form when the Spanish maker Antonio Torres increased the size of the body, altered its proportions, and introduced the revolutionary "fan" top bracing pattern, in around 1850. His design radically improved the volume, tone and projection of the instrument, and very soon became the accepted construction standard. It has remained essentially unchanged, and unchallenged, to this day.