The actor and producer were on a promotional trip in Amritsar and took time out to visit Darbar Sahib.
Shah Rukh even tweeted an image with AbRam. They were both dressed in black and covered their head using an orange cloth.
The actor wrote: "At the Sri Darbar Sahib. Peace and love and all feelings beautiful. Thank you Amritsar."
The visit was a personal outing undertaken by them to express their gratitude for the appreciation garnered by their movie, said a statement issued on behalf of the makers.
Of his experience, Shah Rukh said: "The peace and serenity one derives at Darbar Sahib is something I feel you can attain nowhere in this world.
"I would firstly like to express my gratitude to Darbar Sahib for the reception of our film."
The visit also proved to be a first time experience for AbRam and Excel Entertainment's Sidhwani.
Before entering the Golden Temple, Shah Rukh said: "It is the first time that Ritesh and my little son AbRam will be visiting the Golden Temple. It was my wife who sent AbRam along with me to seek blessings. I am very happy to be here."
"Raees", which also features Nawazuddin Siddiqui and Mahira Khan, has been getting a good response at the box office.
Shah Rukh essays a bootlegger in the film, set against the backdrop of liquor prohibition in Gujarat.