Modi, who arrived at the Himalayan shrine two days ahead of its annual closure for the winter season, spent two hours here.
He spent around 15 minutes inside the sanctum sanctorum of the famed temple performing Rudrabhishek of lord Shiva to whom the shrine is dedicated.
The rituals were supervised by chief priest of Kedarnath T Gangadhar Ling and Modi's teertha purohit Praveen Tiwari.
After emerging from the sanctum sanctorum, Modi took a round of the temple and also paused for a while to take in the beauty of its snow-covered surroundings.
Uttarakhand Governor Baby Rani Maurya, Chief Minister Trivendra Singh Rawat and Chief Secretary Utpal Kumar Singh were with the prime minister while he offered prayers at the temple and reviewed at length reconstruction works at Kedarpuri. He also visited a photo gallery put up in the temple precincts chronicling the reconstruction of areas close to the shrine which were extensively damaged during the 2013 tragedy.
He waved to devotees and locals standing on either side of the Aastha Path leading to the shrine and extended Diwali greetings to them.
Modi walked through Kedarpuri to take stock of the reconstruction projects at the township and later went in a slow moving vehicle to see the retaining walls built on the banks of Mandakini and Saraswati rivers.
Modi had laid the foundation stone of five reconstruction projects at Kedarpuri last year and has been closely monitoring their progress via video conferencing.
He also went to see a medical facility built near the temple and the samadhi of Adi Guru Shankaracharya which is being rebuilt after being demolished by the catastrophic deluge of 2013.
Earlier, in keeping with his practice of celebrating Diwali every year with soldiers, the prime minister visited Harsil close to the Indo-China border in Uttarkashi district and spent over an hour with them.
Addressing the soldiers in the presence of Army Chief Gen Bipin Rawat, Modi saluted their spirit of braving odds to serve the nation.