Mughal rulers used this fort as a prison for chiefs and nobles of status. Emperor Jahangir ordered the incarceration of Guru Hargobind here at the instigation of the Guru’s detractors. However, when the Sufi Saint Mian Mir and other sympathizers interceded, the Emperor ordered the Guru’s release. When the imprisoned nobles heard of his release, they looked up to him for his assistance as a man of God, pious as well as brave. Guru Hargobind refused to be released unless the other internees were also let out. The emperor agreed to release as many of them as could come out holding the fringe of the Guru’s robe. The Guru, narrate the chroniclers, had a long robe made with many strings attached to it which enabled all the fifty-two captives to come out of the fort with him.
This earned for the Guru the epithet Data Bandi Chhor, lit. the munificent liberator. Chroniclers differ about the dates and duration of the Guru’s detention. But it appears that it was only for a few months sometime between 1617 and 1619.
A shrine bearing the name was established inside the fort. It was looked after by Muslim priests until the Sikhs acquired possession and established a Gurdwara after the Independence in 1947. The original shrine in the form of a marbled platform is still maintained near the entrance to Gurdwara Data Bandi Chhor Patshahi 6 Guru Hargobind Sahib Ji, as it is now named. The present building complex spread over six acres was constructed under the supervision of Sant Jhanda Singh and Utam Singh Mauni of Khadur Sahib during the 1970s and 1980s. The principal building is a six-storey edifice near the old shrine. The sanctum is on one side of a high-ceilinged, almost square hall on the ground floor. There is a basement below of the same size as the hall and four storeys of room above the sanctum. Guru ka Langar with its vast dining hall and residential rooms for staff and pilgrims are in a separate, adjoining compound. It is a peculiarity of this Gurdwara to have two sarovars, one for women the other for men.