Prophet Muhammad (PBUH) received the first revelations when he was 40 and after 13 years of inviting people of Mecca to Islam, migrated to Medina as a result of pressures by his enemies.
The Prophet passed away in Medina on the 28th of [the Islamic calendar month of] Safar in year 11 Hijri (632 CE). He established the first Islamic government and devised Islamic rules while in Medina.