India's Modi makes unscheduled stop at church bombed in Sri Lanka Easter attacks
Modi's entourage made a detour to St Anthony's shrine on their way to President Maithripala Sirisena's office, where a red carpet military parade awaited.
"I am confident Sri Lanka will rise again," Modi said on Twitter while posting photos of himself at the church.
"Cowardly acts of terror cannot defeat the spirit of Sri Lanka. India stands in solidarity with the people of Sri Lanka."
Modi is stopping in Colombo on his return home after an official visit to neighbouring Maldives, where he inaugurated a coastal radar system and military training centre.
His brief but politically significant visit to the two neighbours comes as New Delhi seeks to fend off Chinese influence on the strategic nations.
The Maldives, a low-lying archipelago of more than a thousand tiny coral islands south of the Indian subcontinent, straddles the world's busiest east-west maritime route.
Sri Lanka is located at a halfway point on the same sea route.
India, the traditional ally of both Sri Lanka and the Maldives, had watched with unease as former governments of strongman leader Abdulla Yameen of the Maldives and Sri Lanka's Mahinda Rajapakse leaned towards Beijing for political and financial support.
Read more: Netanyahu praises election victory of pro-Israel India PM Narendra Modi
Yameen's election loss last September, however, has seen the new administration under President Ibrahim Mohamed Solih swing back towards New Delhi.
Colombo too has moved back to New Delhi after the defeat of Rajapakse in January 2015.
Last month, Colombo announced entering into partnership with India and Japan to develop a deep-sea container terminal next to a controversial $500-million Chinese-run facility in the capital.
A memorandum of cooperation (MOC) had been signed between the three countries to develop what is known as the East Terminal of Colombo port.
China owns 85 percent of the adjoining Colombo International Container Terminal, which was commissioned in 2013. The state-owned Sri Lanka Ports Authority owns the remaining 15 percent.
More than two thirds of transhipment containers handled by Colombo originated from or was destined for India.
Sri Lanka, unable to repay a huge Chinese loan, handed over another deep-sea port in the south of the island to a Beijing company in December 2017 in a deal that raised concerns at home and abroad.
Follow us on Twitter: