Medina is the second holy city of Islam, after Makkah (Mecca). Its importance as a religious site derives from the presence there of the Masjid al Nabawi, the Mosque of the Prophet, which was built on the site of Muhammad's home and is where he is buried. The first mosque of Islam is also located in Medinah and is known as Masjid al Quba.
In 622, Medina became the seat of Muhammad's growing movement after the Hegira. In 622 Muhammad was invited to come and live in Yathrib (the old name of Medina) and act as a sort of governor. Medina in those times was a divided city. Different clans and religions were eternally quarrelling and bickering and Muhammad brought unity to the city. All parties agreed to a pact drawn up by Muhammad and his followers. He invited all people in the city to follow the new religion of Islam. He had trouble however to convince the Jewish population (which was actually quite large) that Islam was the true version of Judaism.
When the Jews refused to convert, the qibla was changed from Jerusalem to Makkah. A small group of converted Jews, however, stuck to the original qibla. They were known as the sect of the Qibla al-Qudsiyya.
In the ten years following the Hegira, Medina formed the basis form where Muhammad attacked and finnaly conquered Makkah. Even when islamic rule was established Medina remained for some years the most important city of Islam and the de facto capital of the Caliphate.
Under the first four Caliphs, known as the Righteous Caliphs, the Islamic empire expanded rapidly and came to include centres of learning such as Jerusalem, Ctesiphon, and Damascus. After the death of Ali, the fourth caliph, Mu'awiyya transferred the capital to Damascus and the importance of Medina dwindled and became of a religious more than a political nature.