PM Modi, who arrived in Nepal on a two-day state visit, went directly to the Janaki temple, dedicated to the Hindu Goddess Sita, from the airport.
Nepalese Prime Minister KP Sharma Oli welcomed PM Modi upon his arrival at the temple complex. He will spend about 45 minutes in the temple.
PM Modi took part in the Shodasopachara Pooja at the Janaki temple, local media reported.
Devotional bhajans dedicated to Goddess Sita and Lord Ram were played during the 10-minute long prayer performed by PM Modi at the temple.
Shodashopachara worship ceremony with sixteen ritualistic services including tantric mantra recitation is carried out only by special guests at the Janaki temple. During the ritual, the idol of Goddess Sita is worshipped and decorated with clothes and jewels.
Former Indian Presidents Neelam Sanjiva Reddy, Gyani Zail Singh and Pranab Mukherjee had performed such prayers during their visits to Nepal, temple priest Ramatpeshwar Das Vaishnav said.
PM Modi is the first Indian Prime Minister to participate in such a worship ceremony at the temple.
Thousands of people gathered at the temple to welcome him.
Later, PM Modi will be accorded a civic reception by the Janakpur Sub-Metropolitan City at Barhabigha ground. PM Modi and Mr Oli will jointly launch Ramayan Circuit to promote tourism in Nepal and India.
Earlier, Defence Minister Ishwar Pokhrel and Province 2 Chief Minister Lalbabu Raut received PM Modi at the airport.
This is the third visit to Nepal for PM Modi and the first high-level visit from India since the formation of the new government in Nepal this year.
Ahead of his visit, PM Modi said India would remain a steadfast partner of the Himalayan nation in its quest for growth and development.
Describing his trip to Nepal as a reflection of his government's commitment to "neighbourhood first" policy, PM Modi had said the Himalayan nation has entered a new era and India would continue to support it.