NEW DELHI — President Obama concluded his three-day trip here Tuesday with a tough-love message to his hosts, as he vowed to be “India’s best partner” in taking its place in the ranks of the world’s great powers but urged it to do more to protect human rights and fight climate change.

In a pointed message wrapped in the language of friendship, Mr. Obama said India needed to combat human trafficking and slavery, elevate the status of girls and women in society, promote religious and racial tolerance and empower young people. He also argued that India had an obligation to curb greenhouse gases despite its economic challenges.

Mr. Obama’s speech was aimed partly at his newfound friend, Prime Minister Narendra Modi, who has been criticized for not doing more to protect political dissent and to guard against sectarian discrimination and conflict. While the two shared a warm visit, Mr. Obama in effect was saying that their developing partnership did not mean Mr. Modi would get a free pass.

“America can be India’s best partner,” he told an audience of 1,500 mostly young Indians at Siri Fort Auditorium before departing the country. “America wants to be your partner as you lift up the lives of the Indian people and provide greater opportunity.”