From Mecca, Guru Nanak went to Madina where He had a dialogue with the Head Priest of the Shrine. Guru Nanak stressed on the unity of God and equality of man. He preached that only a man's good deeds help a man to get liberation.
From there Guru Nanak travelled further and visited Syria, Turkey, Egypt, Ethipia and other African countries. Then they travelled further across the Arabian dessert and reaches Baghdad.
The Guru and Bhai Mardana sat near a tomb outside the town. There he asked Bhai Mardana to tune the rebeck and the Guru began to sing hymns in praise of God. When the people of surrounding area heard the voice of the Guru they came to hear the music.
But in Muslim countries music was considered as an act of sacrilege. The people complained against it to the Head Pir of Baghdad.
Head Pir sent his men to bring Guru Nanak.
But the Guru said, 'I am not a slave of Pirs, I believe in One God and I obey His order only.'
In the evening He uttered a call to prayer in the style of Muslims. He uttered the call in such a sweet and loud voice that people of Baghdad were enchanted to hear it. They flocked to see the Faqir.
On hearing Pir Dasgir himself turned up and sat near Him. His learned son and other followers were also with him.
The Pir said, 'Who are you and to which dynasty of Faqirs you belong?'
The Guru answered, 'My name is Nanak and I believe in One God. As God does not belong to any dynasty, religion and country, so being His humble servant, I do not belong to any dynasty, religion and country. God is perfect. He is inaccessible and limitless. He Himself is One and Himself Infinite. There are millions of heaven and millions of underworlds. He is present everywhere.'
Pir Dastgir was astonished to hear such an answer from Guru Nanak.
But son of Pir said, 'We believe in seven heavens and seven underworlds. How could you claim millions of heavens and underworlds?'
The Guru placed his hand on the forehead of the son of the Pir and asked him to close his eyes. Then within a few minutes Pir's son saw millions of heavens and underworlds. He told all about these worlds to his associates.
All fell on the feet of Guru.
There Guru Nanak met another Faqir, whose name has been mentioned as Shah Bahlul. Guru Nanak made him one of his most ardent devotees.
It is said that Pir Bahlul Shah sat for sixty years at the foot of the slab occupied by Guru Nanak during his stay at Baghdad.
During his journey of west, Guru Nanak showed the true path to the people by traditions mentioning similes from Islamic traditions.
During this period his poetry became more idealistic and philosophical. The outstanding feature of His poetry is that there is no bitterness in his criticism.
Bhai Gurdas Ji says the following of Guru Nanak Dev ji's visit to Baghdad:
From Mecca Baba went to Baghdad and stayed outside the city.
Firstly, Baba himself was in the form of Timeless and secondly, he had his companion Mardana, the rebeck player.
For namaz (in his own style), Baba gave call, listening to which the whole world went into absolute silence.
The whole city became quiet and lo! to behold it, the pir (of the town) also got wonderstruck.
Observing minutely he found (in the form of Baba Nanak) an exhilerated faqir.
Pir Dastegir asked him, which category of faqir you belong to and what is your parentage.
(Mardana told) He is Nanak, who has come into kaliyug, and, he recognises God and His faqirs as one.
He is known in all the directions besides earth and sky.