Passover must fall in spring. The Hebrew calendar is lunar. Those two requirements are incompatible without correction, and the correction is the calendar's central mechanism.
Twelve lunar months come to about 354 days, eleven short of the solar year. Left alone, the festivals would move backwards through the seasons at the rate the Islamic calendar does. The Hebrew calendar prevents this by intercalation: in seven years out of every nineteen, years 3, 6, 8, 11, 14, 17 and 19 of the cycle, a whole extra month is added, a second Adar, before Nisan. Nineteen solar years and 235 lunar months differ by about two hours, which is why the nineteen-year cycle is used by every lunisolar calendar that has ever worked.
The month begins from the molad, the calculated mean conjunction, whose value, 29 days, 12 hours and 793 parts, is accurate to within about half a second of the true mean and was established by Babylonian astronomers around 300 BCE.
Four postponement rules then adjust the start of the year, to prevent the Day of Atonement falling adjacent to a sabbath and to prevent certain awkward sequences, and these produce the six possible year lengths: 353, 354 or 355 days in ordinary years, and 383, 384 or 385 in leap years.
The system replaced an earlier practice of observation, in which witnesses reported the new moon to the court and an extra month was declared when the barley was not ripe. The transition was gradual, running from the first century to about the tenth; the traditional ascription of the fixed calendar to Hillel II in 359 is not well supported.