"It may seem surprising when you think about all the innovation coming out of India, but 630 million people there defecate in the open because they don't have access to a commode. Worldwide, the number is 2.5 billion people," Gates said in his blog which he also tweeted and tagged Modi. Modi later retweeted Bill Gates' tweet.
Praising Modi, the philanthropist said: "This is not the kind of issue that most politicians like to talk about. But I would guess that in the short time he has been in office, Modi has done more to raise the awareness of the need for toilets than any other leader since the country gained independence."
Gates quoted the New York Times that described Modi - before his trip to the US - as the prime minister who had "pledged to cut through red tape, stamp out corruption, revive India's economy and restore pride".
But, Gates said, the Indian prime minister, who took charge in May, has also been quite outspoken on a subject you hear much less about: open defecation.
"Modi has India talking about toilets - and that's a great thing," said Gates, who had met Modi Sep 19 during his India visit. Gates also posted his photograph with Modi.
"Creating good sanitation options for people - a safe place to poop - is a big focus of our foundation. So when Melinda and I met the prime minister in New Delhi last month, toilets were high on the agenda, along with vaccines, bank accounts, and health clinics. We came away impressed by his commitment to fighting poverty and improving health for India's poorest people," said the founder of the The Bill and Melinda Gates Foundation in his blog dated Oct 6 titled 'Impressions of India'.
"This was the third time Melinda and I had visited India together (we had each made several visits on our own too). It was an especially busy time there; President Xi (Jinping) of China was also visiting, and the government was responding to the deadly floods in Jammu and Kashmir," he said.
But, he said Modi and he ended up talking for more than an hour.
"Judging from our time there, it sounds like he's setting aggressive goals and pushing people to get them done quickly. He's having a lot of intense meetings with various ministers, asking them, "What can you do in 100 days? Can you make your goals more concrete? More ambitious?"
"We may have spent more time talking about sanitation than anything else. It was hardly the first time Melinda or I had discussed the topic in India, but usually we were the ones to bring it up. This time, the prime minister did. He made it clear that he is frustrated with the slow pace of improvement."
Gates said Modi wants to end open defecation by 2019 and discussed installing toilets in bus and rail stations in the country's 500 biggest towns.
"I talked about the opportunity to design 21st century toilets that don't need big sewage systems and water treatment plants," he said, adding that his foundation has co-hosted two Reinvent the Toilet fairs, including one in New Delhi.
"Some of the potential new designs take human waste and use it to create energy, fertilizer, or even drinkable water," he said.
Gates, however said, that the talks were not just limited to toilets.
"We also discussed several other priorities of the prime minister's, including extending banking services to every adult in the country. (Having a bank account is essential in building savings and escaping poverty-but today fewer than half of Indians have one)."
He went on to say that they "talked about India's fantastic decision to provide its home-grown rotavirus vaccine to every child, as well as the prime minister's efforts to fight malnutrition-which includes a particular focus on educating women and girls about good nutrition".
"This is an exciting time, not just for India, but for everyone who cares about giving the poorest people a chance to lead healthy, productive lives. With all the attention and innovation going on in these areas - from health to financial services - we have a fantastic opportunity to make an impact. It's inspiring to see India moving to the forefront of these efforts," Gates added.