The two met for the first time after PM Modi's surprise visit to Lahore on December 25, 2015.
PM Modi and Mr Sharif are attending the summit of Shanghai Cooperation Organisation (SCO) where India and Pakistan will be inducted as full members of the bloc today.
Official sources said they were in the Leaders' Lounge at the Astana Opera before the SCO concert, where they exchanged greetings.
"Since it was the first occasion when the two leaders came across each other after Sharif's operation, PM Modi enquired about his health. He also enquired about Sharif's mother and family," a top source said.
Mr Sharif had an open-heart surgery in June last year.
Earlier in the day, when asked whether he will have a meeting with PM Modi, Mr Sharif had smiled and waved at reporters, a gesture that was seen by many as a hint of a possible meeting or at least a pull-aside between the two leaders.
Ties between India and Pakistan have nosedived over a series of attacks from across the border, including the beheading of two soldiers by Pakistanis last month and multiple infiltration attempts by terrorists.
In December 2015, PM Modi had made a surprise stopover at Lahore on his way home after a trip to Afghanistan. It was the first visit to Pakistan by an Indian Prime Minister in more than 10 years.
However, days later on January 2, Pakistan-based terror groups carried out an attack on an Indian Air Force base in Pathankot.
The foreign ministry, asked about the possibility of a bilateral meeting between PM Modi and Mr Sharif on the sidelines of the SCO summit, had said neither Pakistani side has requested a meeting, nor does India have any such proposal.
PM Modi, Mr Sharif, Russian President Vladimir Putin and Chinese President Xi Jinping were among top leaders who attended the reception hosted by Kazakhstan President Nursultan Nazarbayev.
At the cultural evening, PM Modi and Mr Sharif were sitting apart.
The cultural event had a Kathak dance performance by an Indian team. It was the only performance from a country which is not yet a member of the SCO.
Get the latest election news, live updates and election schedule for Lok Sabha Elections 2019 on ndtv.com/elections. Like us on Facebook or follow us on Twitter and Instagram for updates from each of the 543 parliamentary seats for the 2019 Indian general elections.