The 83-year-old, who was accompanied by Bollywood filmmaker Vishal Bhardwaj on the trip, wrote a letter on Thursday, titled "Mujh Se Naraz Na Hon (Don't be cross with me)", to the founder and organiser of the festival Ameena Saiyid.
According to the letter, it was during Gulzar's visits to his birthplace Dina and to Ahmed Nadim Qasmi's gravesite that he felt "uneasy in the chest". When the discomfort continued he decided to go back to Mumbai.
He apologised to the people of Pakistan for not attending the festival and wished the event a success, reported Dawn newspaper.
"While at Lahore, I had taken the opportunity to visit Dina to have a look at the house where I was born and spent my teens and of course the Qaber of my late guru and mentor Ahmed Nadeem Quasmi to pay my respects," Gulzar wrote in the letter.
"I was moved very much by these two visits. As ill-luck would have it, I felt very uneasy in the chest. The uneasiness subsided temporarily at the recording studio.
"We were recording a song for Vishal with Pakistani singers. The discomfort returned when I reached the hotel. It was 2am Vishal postponed the recording for a later date some time in March and we impulsively decided to return to Mumbai, which being a familiar terrain to meet such contingencies.
"Thus I reached Mumbai on 13th night. I had come fully prepared for The Karachi Literary Festival. But this mishap has disappointed me very much. I am awfully sorry for this, which is beyond my control. With very best wishes for a very successful festival," he added.