"First of all he [Numa] divided the year into twelve months, corresponding to the moon's revolutions. But as the moon does not complete thirty days in each month, and so there are fewer days in the lunar year than in that measured by the course of the sun, he interpolated intercalary months and so arranged them that every twentieth year the days should coincide with the same position of the sun as when they started, the whole twenty years being thus complete."
Livy, History of Rome (I.19)
The beginning of the month originally was marked by the sighting of the new moon, just visible as a thin crescent. But the moon's monthly orbit around the earth (lunation) is not constant, nor is the interval between the conjunction of the new moon and its first appearance, or even the number of lunar months in the solar year. Although a natural measurement, the synodic month (the time from one new moon to the next) is an awkward means of measuring time, which should be determined by the tropical year (the time from one vernal equinox to the next). A lunisolar year must be regulated in such a way that the number of days in the solar year and the lunar months are consistent over a given period of time. If, for instance, lunations are longer than the months, it is necessary to intercalate a certain number of days in every cycle to bring them back into agreement with the phases of the moon but still not disrupt the agreement of the calendar with the solar year.
Livy relates that Numa sought to regulate the lunar year by inserting intercalary months so that, at the end of every nineteen-year period, the lunar and solar year would coincide. This is the Metonic cycle, named after Meton, who introduced it at Athens in 432 BC (and was satirized by Aristophanes in The Birds). It comprised nineteen tropical years or 235 synodic months, seven of which were intercalated (235 = 19 x 12 + 7). This allowed the first month of the new year to coincide with the vernal equinox and the beginning of each month to agree, as well, with the course of the moon. Every nineteenth year, the sun and moon returned to their same positions on the ecliptic, the sun to the same longitude after a whole number of years, the moon to the same phase after a whole number of months.
About 330 BC, Callippus formulated a more accurate version of Meton's cycle, which averaged a bit more than 365.25 days per year (the Gregorian year is somewhat less). By combining four Metonic cycles into a 76-year cycle and then dropping one day, he was able to establish the correct number of days in the year (27,759 / 76 = 365.25). It was this number that became the basis for the Julian calendar.
To bring the lunar calendar into phase with the solar year, an additional month (Intercalaris or Mercedonius, from merces, "wages," which were paid then) of 27 days was intercalated every other year after February 23 or 24 in place of its remaining four or five days (or, to phrase it another way, the last four or five days of February were added to the 22 or 23 days needed to comprise an intercalary month of 27 days). Such a year consisted of 377 or 378 days, and a four-year cycle comprised 355, 377, 355, and 378 days, or 366.25 days a year. But, even though the mean length of this embolismic year (one which has been intercalated) was only a day longer than the solar year (365.25 days), it never occurred to the Romans to drop the extra day, with the result that the calendar gained a day every year. If, instead of alternately intercalating these 22 or 23 days to a year of 355 days (ninety days in eight years or 11.25 days a year), the Romans had added them to a lunar year of 354 days, the Julian calendar would have been created much earlier.
Just as the intercalary month derived from merces, the etymology of "calendar" is from Kalendarium, an account book in which debts were entered and interest paid, which was due on the Kalends of every month. Too, that March originally was the first month of the year can also be seen in the celebration of the Terminalia on February 23, which, as its name implies, marked the end of the year (Macrobius, Saturnalia, I.13.14).
The etching above is Numa Pompilio Receiving the Laws from the Nymph Egeria by Bartolomeo Pinelli (1781-1835), Achenbach Foundation for Graphic Arts (Fine Arts Museums of San Francisco).