Guru Nanak was born in 1469 and died at the age of 70 in 1539. Guru Nanak's life is well documented and there are records in the Babur nama which chronicle a meeting between him and the Mughul emperor Babur before the first battle of Panipat in 1526.
It is also mentioned in the Janam Sakhi's ( stories of Nanak's life) that he made 4 long travels, beginning from 1498. His first travel is reported to Mecca and then to Baghdad. The Guru reportedly traveled from Gujarat to Arabia by sea and then by a caravan to Mecca. After that he continued to Baghdad and returned back to Punjab by the land route.
The tale of Nanak visiting Mecca is popular in Sikh folklore and literature and his miracle there has been retold thousands of time. Guru Nanak when in Mecca reportedly fell asleep with his feet towards the Kaaba. This enraged a Qazi,who ordered Nanak to remove his feet from the direction of the Kaaba. Angrily the Qazi caught and turned Nanak's feet away from the Kaaba, but lo and behold to the wonder of the Qazi, the Kaaba also turned. In other words the Kaaba followed the Guru's feet. The Qazi realized that he was in company of a great Pir. He also realized that god is everywhere and fell at the feet of Nanak.
Despite this, there is no account of Nanak's visit in any Muslim source. So the question is that did Nanak visit really visit Mecca? Also it must not be forgotten that no non-Muslim could enter Mecca on pain of death. This is in force even today. One or two Englishmen like Sir Richard Burton did visit Mecca, but disguised as Muslims. So where do we go from here?
The clue to this lies in the reference to Nanak as Pir( Muslim holy man) in some Muslim sources. He also wore a choga(robe) with verses from the Koran written all over it. This choga is available at Dera Baba Nanak close to Ferozepur and is in the custody of the Bedi family.What does this signify? Muslim scholars point to the choga and say that Nanak visited Mecca on Haj as he had converted to Islam Further no research is permitted in Mecca itself as it is forbidden by the Saudi government. Thus it is even more difficult to unravel the truth.
We also know that Nanak was NOT a Muslim and never embraced the Islamic faith, though he had regard for Mohammed. Yet there is evidence that Nanak visited Baghdad and a recent placard on stone at Istanbul ( Turkey) mentions that Nanak visited that place. So the probability of guru Nanak having visited Mecca is very plausible .The only point is that he wore the Choga with the sayings from the Koran and everybody took him to be a Muslim. If some research were allowed in Mecca, perhaps some evidence of Nanak having come there may turn up. At this stage we can conjecture that probably Nanak did visit Mecca, but he passed of as a Fakir or holy man and nobody questioned him.
The miracle at the kaaba should not be taken literally and merely is Nanak's way of showing that God is everywhere. In fact this forms the first stanza of his morning prayer "The Jap". The Choga is the big mystery and the fact that it has verses from the koran written all over it has no explanation. This was pointed out in 1897 by Mirza Ghulam Ahmed, the founder of the Ahmadiyya community after an examination of the choga in the presence of the custodian.
Setting this aside, one can conclude that Nanak did visit Mecca and his further travels to Baghdad and Istanbul only confirm it.