Spurning official talks in the capital Islamabad, India's leader chose instead to make an intimate trip to Sharif's ancestral residence near Lahore Friday, where he was celebrating his birthday and the wedding of his granddaughter.
A source present in the meeting said the leaders of the nuclear-armed arch-rival nations "chatted like old friends" as they ate vegetarian food, with the Indian premier telling Sharif, "Your sincerity is beyond doubt".
Modi's stunning decision to drop in for talks with Pakistan's leader -- something ex-premier Manmohan Singh failed to achieve in ten years of power -- was roundly welcomed in India, where it was seen as a calculated personal gamble.
"Modi has made clear he is willing to risk political capital to make peace," the Indian Express newspaper said, warning that any future terrorist attacks traced to Pakistan would invite "savage criticism".
The visit, announced by Modi on Twitter, gave the appearance of being spontaneous, with Sharif's foreign affairs adviser not able to reach Lahore in time. However, a senior Pakistan official told AFP that security had been planned days in advance.
While Indian media suggested Modi was the driving force behind the visit, a Pakistan official said it was Islamabad's idea to arrange a meeting ahead of formal diplomatic talks set for January.
"The goal behind this meeting was to humanise the other side by arranging a visit involving close family members," said the official, adding that some of Sharif's cabinet had opposed the visit.
Television polls suggested most Indians welcomed the development while newspapers praised Modi's decision to avoid weighty expectations by staging an informal "stopover" on the way back from Kabul.
"Traditional build-up to an Indian PM's visit to Pakistan would have seen different interest groups bringing all kinds of pressure to bear," The Times of India said.
Yet members of the opposition Congress party denounced the "unpredictable" act, calling it un-statesmanlike, with some complaining such an important meeting should not have been announced on Twitter.
Others questioned whether the newfound friendship would translate into concrete progress on peace, thwarted by issues such as India's fear of Pakistan-sanctioned terror attacks and violence-plagued Kashmir.
In his 18 months in power Modi has shown huge confidence in his political skills, announcing economic policies himself and fronting a key state election campaign in Bihar -- unsuccessfully -- instead of fielding a candidate.
"Modi loves to spring surprises -- he's disruptive, he's setting aside old taboos," Neelam Deo, a director at Gateway House think-tank in Mumbai told AFP.
"He's personalised diplomacy to an extent we haven't seen in India since (India's first prime minister) Jawaharlal Nehru in the 1950s," she said, adding the visit was likely part of a broader strategy.
Modi and Sharif have had a stop-start diplomatic relationship since the Indian premier's surprise decision to invite Sharif to his inauguration in May 2014.
A brief meeting on November 30 between the two leaders on the sidelines of the UN climate summit in Paris, followed by talks between their national security advisers in Bangkok, appeared to have broken the ice.
"Modi has once again shown himself to be a bold risk-taker in foreign policy," said Sadanand Dhume of the Washington-based American Enterprise Institute.
The last visit to Pakistan by an Indian Prime Minister was in 2004 by then leader Atal Bihari Vajpayee, who is credited with bringing about a thaw in relations with Islamabad. - AFP