The Islamic lunar calendar (also referred to as Hijri calendar) is a purely lunar calendar. It contains 12 months that are based on the phases of the moon. Each lunar month is approximately 29.53 solar days. Therefore, the Islamic calendar is shorter than the Gregorian calendar. 12 lunar months is about 12 x 29.53=354.36 days (10 to 11 days shorter than the solar calendar). This why you may have noticed that the month of Ramadan and the time of Hajj gets earlier each year.
Names of Months
The 12 months of the calendar are:
3. Rabi' al-awwal (Rabi' I)
4. Rabi' al-thani (Rabi' II)
5. Jumada al-awwal (Jumada I)
6. Jumada al-thani (Jumada II)
11. Dhu al-Qi'dah
12. Dhu al-Hijjah
These months have been in existence since before the time of the Quran.
The Islamic lunar calendar, was first introduced in 638 AD by the second Caliph (Khalifa in Arabic), `Umar ibn Al-Khattab. The starting point of the calendar however was set to about sixteen years earlier, to mark the Hijrah — i.e. the time of emigration of the prophet Muhammad from Mecca to Medina. The word hijrah means to leave a place to seek sancturary or freedom from persecution or freedom of religion (or any other purpose). The emigration to Medina was a historic event, as it marked the turning point from persecution to freedom and acceptance of Submission (Islam in Arabic).
The actual starting date for the Calendar was chosen to be the first day of the first month (1 Muharram) of the year of the Hijrah. The Islamic (Hijri) calendar is usually abbreviated A.H. in Western languages (similar to A.D. used to mark the Christian calendar). Muharram 1, 1 A.H. corresponds to July 16, 622 A.D.
Note that the actual month names such as Muharram and Ramadan, were in existence prior to the establishment of the Hijri calendar. That is why, God says in Quran 2:185 "Ramadan is the month during which the Quran was revealed, providing guidance for the people, clear teachings, and the statute book. Those of you who witness this month shall fast therein. ..."
Quranic References to Calendar & Months
Both the sun and the moon are described as "calculation devices" for the people (Quran 6:96). Thus, while we use the sun for determining the times for prayer, in our daily activities and in clocks worldwide, the lunar calendar is also used to determine the times for Ramadan and Hajj.
[6:96] At the crack of dawn, He causes the morning to emerge. He made the night still, and He rendered the sun and the moon to serve as calculation devices. Such is the design of the Almighty, the Omniscient.
Specifically, the phases of the moon are cited as a timing device for the people in Quran 2:189 and 10:5.
[2:189] They ask you about the phases of the moon! Say, "They provide a timing device for the people, and determine the time of Hajj. ...
[10:5] He is the One who rendered the sun radiant, and the moon a light, and He designed its phases that you may learn to count the years and to calculate. GOD did not create all this, except for a specific purpose. He explains the revelations for people who know.
God makes it very clear in the Quran that there are twelve months. We are also told that four of these months are sacred (months 12, 1, 2, 3). While some muslims alternate the sacred and regular months, God condemns this in Quran 9:37. Thus we know that all the four sacred months are sequential (i.e. one after the other).
God's System: Twelve Months Per Year*
[9:36] The count of months, as far as GOD is concerned, is twelve.* This has been GOD's law, since the day He created the heavens and the earth. Four of them are sacred. This is the perfect religion; you shall not wrong your souls (by fighting) during the Sacred Months. However, you may declare all-out war against the idol worshipers (even during the Sacred Months), when they declare all-out war against you, and know that GOD is on the side of the righteous.
[9:37] Altering the Sacred Months is a sign of excessive disbelief; it augments the straying of those who have disbelieved. They alternate the Sacred Months and the regular months, while preserving the number of months consecrated by GOD. They thus violate what GOD has consecrated. Their evil works are adorned in their eyes. GOD does not guide the disbelieving people.