Very briefly:
Ancient Greek dialects were very distinct between them in the beggining but mutually undestandable (with many dificulties).
So we had 3-4 major dialects: Ionian, Dorian and Aeolian and many variations between each branch: Acarnanian, Cypriot, Boeotian, Arcadian, Magnesian, Attic, Epirotic etc, almost every district had a different variation.
As Athens became the center of the arts in ancient Greece, it's dialect became more and more widely used, especially from the upper classes all over the Greek world. With Alexander's globalization, it bacame the official language because it was mutually understadable by most Greeks. Actually it was even simplified a bit and the new version was called "Koine", meaning "Common". The New testament was written in Koine Greek.
Koine Greek was used in the Byzantine empire.
Later on, after the Ottoman conquest, another form started to appear deriving from Koine. That was the "Demotic" (from "Demos", people) Greek. That was an even more simplified form of Greek but similar to Koine. It spread quickly amongst the people since there was no significant Greek literature under the Ottomans and it was quite more simple in Grammar as well as Syntax.
After the libaration and the establishment of the Hellenic state, there was an effort to re-establish a form of Attic, called "Katharevousa" (pure). It was used mainly in literature and today it's much less used. So modern Greek is the "Demotic" variation.
Many people ask if I can understand ancient Greek. The answer is that although I never had ancient Greek classes, I can read ancient text, but I have trouble understanding the exact meaning because of the differences in grammar.
Here're some links with the history of Greek language:
http://www.greece.org/gr-lessons/gr-english/history.html
http://www.greek-language.com/historyofgreek/