A devout Hindu, 63-year-old Modi was at the temple of Lord Shiva for about 45 minutes on a 'Shravan ashtami' which is considered auspicious.
"Felt extremely blessed on offering prayers at Pashupatinath Temple this morning," Modi tweeted after offering the puja at 5th century temple on the second and last day of his maiden trip to Nepal after assuming office in May.
He donated 2500 kgs of sandalwood to the Pashupatinath Temple which is located on the banks of the Bagmati River in Deopatan, a village 3 km northwest of Kathmandu.
Modi, in saffron dress, emerged from the temple wearing 'rudraksh malas'.
More From This Section
In the visitors' book, the Prime Minister wrote that the temple is "unique".
"Pashupatinath and Kashi Vishwanath (of Varanasi) are the same. I am full of emotions and I pray that the blessings of Pashupatinath, which unite Nepal and India, may continue for people of the two countries," wrote Modi, who was elected to Parliament from Varanasi, the city known as the abode of Lord Shiva.
The Pashupatinath temple is dedicated to a manifestation of Shiva called Pashupati (Lord of Animals). It attracts thousands of pilgrims each year, mostly from India.
There is a tradition of keeping four priests and one chief priest at the temple from among the Bramhins of south India for centuries.