It is reported that when Muhammad (pbuh) was around the age of forty years, he used to go to a cave named "Hira", with some rations and used to spend his time meditating and worshipping his Lord, at the age of forty during the same process of meditation an angle "Gabriel" appeared to him revealing the first verse of the Holy Book of Islam.
But as described in Muslim history and Holy Books, it was not only the meditation which rose him to prophet hood, it was his devotion and love for his Lord and he had been chosen to become a prophet even before his birth as in Islam prophet hood is a rank which no one can attain by force or with his own efforts rather than it is Allah’s choice whomsoever He chooses.