Around 50,000 people gathered for what Mr Trump called a “profoundly historic event” on Sunday in Houston.
The “Howdy, Modi!” event was billed as one of the largest ever receptions of a foreign leader in the US.
Mr Modi, however, may face a frostier reception at the UN General Assembly.
He is likely to face criticism over tensions in Indian-administered Kashmir, which he stripped of its special status last month, promising to restore the region to its “past glory”.
Trade talks and the UN General Assembly are on the Indian prime minister’s agenda during his week-long visit to the United States.
A 90-minute show, featuring 400 performers, warmed up the crowd before Mr Modi and Mr Trump shared the stage.
“I’m so thrilled to be here in Texas with one of America’s greatest, most devoted and most loyal friends, Prime Minister Modi of India,” Mr Trump told the crowd.
In his speech, Mr Modi said India has a “true friend” in the White House, describing Mr Trump as “warm, friendly, accessible, energetic and full of wit”.
“From CEO to commander-in-chief, from boardrooms to the Oval Office, from studios to the global stage… he has left a lasting impact everywhere,” Mr Modi said.
Personal-touch diplomacy played to perfection
Brajesh Upadhyay, BBC News, Houston
This was exactly the kind of crowd size and energy President Trump loves at his rallies.
Only here the chants were for Indian Prime Minister Narendra Modi and Mr Trump was the superstar invited to the party. But the crowd did not disappoint him either and greeted him with chants of “USA!”, most heard at Trump rallies.
The personal-touch diplomacy with Mr Modi’s trademark bear hugs was played to perfection.
This rally has been called a win-win for both the leaders. For President Trump, it was a chance to court Indian-Americans for the 2020 presidential election race where Texas could emerge as a battleground state. For Mr Modi, a PR triumph and picture with the president of the United States may help him shrug off the criticism over his recent strong-arm polices at home.
Houston’s NRG Stadium, where the event was hosted, was the first stop for Mr Modi, whose Hindu nationalist Bharatiya Janata Party (BJP) won a landslide victory in this year’s Indian elections.
Greeted by a standing ovation, Mr Trump used his speech to heap praise on Mr Modi, who he said was doing a “truly exceptional job for India” and its people.
Mr Trump also paid tribute to the Indian-American community, telling them “we are truly proud to have you as Americans”.
No stranger to nationalist rhetoric himself, Mr Trump compared security at the US-Mexico border to the tensions between India and Pakistan in the tinderbox Kashmir region.
“Both India and US also understand that to keep our communities safe, we must protect our borders,” Trump said.
In India, the rally was closely watched, with most mainstream media outlets running live news updates of what was transpiring at the rally.
The event had been making headlines for days before as well.
On Twitter, many people shared instant analysis and opinions of what was taking place on the stage with the sentiment being largely positive. Many praised Mr Modi for what they saw as his statesmanship and diplomatic acumen with a lot of praise coming in for the US president as well.