The history of the guitar in many ways reflects the evolutionary nature of human thought, complete with its own branches of development. The end result has been a plethora of stringed instruments that all share many important characteristics of the guitar while producing a slightly different sound.
Prehistory, pre-guitar
There are so many different stringed instruments around that in some cases it's hard to know whether or not to call something a guitar at all, and it gets even harder the further you go back in time. The version of the guitar that we usually think of is relatively new in the history of music. But the roots of the guitar go way, way back into the fog of prehistory.
We know that stringed instruments were prevalent in ancient Greece, adopted from the Egyptians and early Mesopotamians. Each instrument in these times would have been handmade and probably quite different from any other. Traveling bards must have had instruments with a different number of strings made of different materials and different shapes, each with its own sound. Before that? Who knows? The earliest ancestors of the guitar have been around were probably around before anyone wrote about it.
Middle ages
Let's not make the mistake of calling it the Dark Ages. For the guitar, it was anything but. It was at this time that several string instruments became popular and were widely recreated in the same style. In Europe, there were a variety of styles of the lute, with its curved back and 4 or 5 courses, but most shared a resemblance in appearance and sound. The Arabs of the Middle East developed the oud, which found its way to Europe with the Moorish invasion of Spain and significantly impacted Medieval music.
The lute stayed around for the Renaissance, but in the melting pot of cultural influence that was Spain, new styles of string instruments were emerging, and the curved shape of the modern guitar finally showed itself in the 1400s. By the end of the 18th Century, these new instruments were becoming standardized and could finally be called guitars as we imagine them.
Today's guitar
Innovation continued in Spain for some time, but development really took off when this instrument reached the Americas in the hands of European immigrants. The flat top acoustic guitar appeared, calling for the use of a pick and an entirely new style of music and sound. Orville Gibson created the archtop guitar, heavily influencing jazz and country before leading to the electric guitar and introducing the world to the stylings of rock-and-roll.
Where the guitar goes from here is anybody's guess. Will it be enhanced by new capabilities in electronics and music production? What will become of the guitar in a world where its sounds can be recreated or even enhanced by a computer? If history teaches us anything, it's that stringed instruments have and probably will always exist in some form or another.