Shah was accompanied by his family members. – his wife, a son, daughter-in-law and granddaughter.
They performed rituals at the temple dedicated to Lord Shiva.
His visit came a day after campaigning for the general election came to a close.
Earlier in the day, Prime Minister Modi offered prayers at the Kedarnath shrine in Uttarakhand.
Polling for the last phase of Lok Sabha elections will take place on Sunday. Counting of votes will take place on May 23.