No extant evidence is known that describes the workings of the oldest Egyptian calendar (that of the pre-dynastic period). We do know that it must have been lunar. Among other things, the hieroglyphic symbol for "month" shows a crescent moon (the first visible crescent of the new moon) over a star. Reconstruction of further detail has been attempted, but the argument remains controversial. Of greater interest for later chronology, particularly astronomical events, is the Egyptian civil calendar, whose existence seems certain by the fifth dynasty, and might, although the evidence is slender indeed, go back to the pre-dynastic period. There is also evidence for a much later, probably unconnected, lunar calendar. It does not, however seem to have been widely used. See Clagett and Parker for further details.
The calendar we know as the Egyptian calendar has no link to the moon at all, although it kept the old hieroglyph. In the Egyptian calendar, there were 12 months of 30 days each. The months each had three "weeks" of 10 days each. Between the end of the 12th month and the beginning of the first month of the next year were five epagomenal (extra) days, resulting in a fixed year of 365 days every year. This calendar, almost a quarter of a day shorter than the tropical year, constantly shifted with respect to the seasons.
For agricultural purposes, the seasons were determined not by the solar equinox or solstice, but by the heliacal rising of the star Sirius (Sothis in Egyptian), which roughly coincided with the flooding of the Nile. Every 1461 Egyptian years (1460 Julian years) the heliacal rising of Sirius came back around to its original position, a time known as the Sothic period. Early interpreters of the Egyptian calendar thought that the Egyptians actually maintained a separate calendar to track Sirius, but in the absence of any evidence, this position has been vigorously disputed by later scholars.
Originally, the months were simply numbered as a month of a season, rather than named. There were three seasons, each of four months. These names suggest that the seasons were originally intended to coincide with the Nile's flooding (and probably did when the calendar was still lunar), but once the calendar took on the form we know they rolled through the seasonal year with the months. From the New Kingdom on, the months are often named.
Years were reckoned by pharaonic reign. For example, one actual Egyptian date appears as "Year 9 under the Majesty of the King of Upper and Lower Egypt Djeserkare. The Feast of the Opening of the Year III Shemu 9. The Going forth of Sothis."
Since Djeserkare is a name for Amenhotep I, we can interpret this as "in year 9 of Amenhotep I, the heliacal rising of Sirius fell in the 3rd month of Shemu, day 9."
This particular date is one of only a handful surviving that record the Sothis rising in terms of the civil year. It's from the so-called Ebers Calendar, and in theory provides a good correlation of the civil calendar to Julina days. Unfortunately, a precise determination of when this fell is impossible. We don't know where the observation was made or what the exact conditions of observation were (which would determine how many degrees above the horizon a star would need to be before being visible to the naked eye. A range of dates, however requires that it be some time in the 2nd half of the 16th century BCE.
In 238 BCE, during the reign of Ptolomy III, the Canopus decree ordered that every four years there should be 6, rather than 5 epagomenal days, in other words, a leap year. Egyptians were very resistant to this change, however, and the attempted reform seems to have failed. An effective implementation of this so-called Alexandrian calendar did not come until Augustus introduced it (25 BCE).
The Egyptian calendar had an importance well beyond its purely Egyptian use. Astronomers used the old Egyptian (not the Alexandrian) calendar throughout antiquity and the Middle Ages because its absolute regularity in the number of days in both the months and the year made calculations much easier. Such regularity was highly desirable, as antiquity had neither arabic numerals nor even the concept of zero to make complex mathematics tractable.