Guitar was, most likely invented in Spain in the 16th century.
It only had 4 courses of strings and was narrower and deeper than the modern guitar.
It was related to Spanish instrument called vihuela.
Between 16th and 19th century further two strings were added, courses of strings were replaced with single strings.
The shape of the guitar’s body and other element of its construction, such as tuning pegs changed as well.
By the 19th century guitar started to resemble and sound like the classical guitar we know today.
Up until the early 19th century guitar was very much an amateur’s instrument with very few known virtuosos.