Washington (CNN) Indian Prime Minister Narendra Modi delivered an ode to U.S.-India relations to a joint session of Congress Wednesday, capping something of a phoenix-like rise for both the man and his country's relations with the U.S.

In an extended speech celebrating the two countries' relationship, he noted that their close ties reflect deeply shared values.

"The traits of freedom and liberty form a strong bond between our two democracies," said Modi, who was greeted by almost three minutes of applause on entering the House chamber. "Our nations may have been shaped by diverse histories, cultures and faiths, yet our belief in democracy for our nations and liberty for our countrymen is common."

"As a representative of the world's largest democracy, it is indeed a privilege to speak to the leaders of its oldest," Modi said.

Modi shakes hands with supporters in Washington upon his arrival on June 6.

Modi shakes hands with supporters in Washington upon his arrival on June 6.

Modi shakes hands with U.S. Attorney General Loretta Lynch at the Blair House in Washington on June 6.

Modi shakes hands with U.S. Attorney General Loretta Lynch at the Blair House in Washington on June 6.

Modi is flanked by U.S. Secretary of Defense Ash Carter, left, and U.S. Army Maj. Gen. Bradley A. Becker.

Modi is flanked by U.S. Secretary of Defense Ash Carter, left, and U.S. Army Maj. Gen. Bradley A. Becker.

Modi lays a wreath at the Tomb of the Unknown Soldier in Arlington.

Modi lays a wreath at the Tomb of the Unknown Soldier in Arlington.

Modi, in white, arrives for a wreath-laying ceremony Monday, June 6, at Arlington National Cemetery in Arlington, Virginia.

Modi, in white, arrives for a wreath-laying ceremony Monday, June 6, at Arlington National Cemetery in Arlington, Virginia.

Obama bids farewell to Modi after a working lunch at the White House on June 7.

Obama bids farewell to Modi after a working lunch at the White House on June 7.

U.S. President Barack Obama listens to Modi during their meeting in the White House Oval Office on June 7.

U.S. President Barack Obama listens to Modi during their meeting in the White House Oval Office on June 7.

Modi speaks during a leadership summit for the U.S.-India Business Council on Tuesday, June 7.

Modi speaks during a leadership summit for the U.S.-India Business Council on Tuesday, June 7.

House Speaker Paul Ryan spends time with Modi during a meeting at the U.S. Capitol on June 8.

House Speaker Paul Ryan spends time with Modi during a meeting at the U.S. Capitol on June 8.

Indian Prime Minister Narendra Modi addresses a joint meeting of the U.S. Congress on Wednesday, June 8. "The traits of freedom and liberty form a strong bond between our two democracies," said Modi, who is in the Washington area for a three-day visit.

Indian Prime Minister Narendra Modi addresses a joint meeting of the U.S. Congress on Wednesday, June 8. "The traits of freedom and liberty form a strong bond between our two democracies," said Modi, who is in the Washington area for a three-day visit.

It would have been hard to imagine three years ago, when U.S.-India relations were in tatters over the arrest and strip search of an Indian diplomat in New York for visa fraud and underpaying her housekeeper. Modi wasn't even permitted to enter the U.S. then, censured for failing to stop the 2002 mass killings of Muslims in the Hindu-majority state he led at the time.

With the Indian leader's election in 2014, the tide has definitively turned -- thanks to determined effort, a growing strategic alignment and the striking odd-couple chemistry between the barrel-chested, bear-hugging Modi and his cool, often restrained American counterpart, President Barack Obama.

Modi, the fifth Indian prime minister to address a joint session of Congress, was interrupted throughout by applause from lawmakers who increasingly see in India a democratic counterweight to China in the Asia Pacific. Modi's repeated references to India's commitment to freedom and democracy served as a reminder that his country offers the U.S. a like-minded partner in an increasingly unsettled region. And that it provides Asia with a model for development and progress more compatible with U.S. values.

"No wonder that the shared ideals and common philosophy of freedom shape the bedrock of our ties. No wonder that President Obama called our ties the defining partnership of the 21st century," Modi said.

Secretary of State John Kerry has said that the U.S. may now do more with India on a government-to-government basis than virtually any other nation. Modi's visit is meant to celebrate that achievement and cement it as this U.S. administration prepares to give way to a new one in 2017.

"This trip is both a love fest and a sales pitch," said Michael Kugelman, a senior associate for South Asia at the Wilson Center.

Modi's goal -- and Obama's -- will be "to highlight the rapid progress made in U.S.-India relations in recent years and to underscore the importance of maintaining the current momentum in relations against a backdrop of changing U.S. leadership," Kugelman said.

Points of friction remain

There are points of friction between the world's two largest democracies, to be sure, with India chafing at U.S. pressure to do more on climate change and human rights, while U.S. lawmakers complain about India's slavery, its loose approach to intellectual property and limits on foreign investment.

Modi raised some of these testier issues with a light enough touch that lawmakers laughed when he said that even though more Americans practice yoga than know how to throw a curve ball, India has yet to claim intellectual property rights on the ancient practice.

JUST WATCHED U.S. returns stolen artifacts worth $100 million to India Replay More Videos ... MUST WATCH U.S. returns stolen artifacts worth $100 million to India 01:08

He teased the lawmakers, telling them he'd heard about the smooth bipartisan cooperation in Congress -- and that he saw the same thing in India. And he sprinkled his remarks with references to American cultural icons such as Abraham Lincoln, Walt Whitman and Martin Luther King -- men who fought for and celebrated freedoms.

Modi's deft performance likely means complaints will be on the back-burner during his visit to Capitol Hill. After his speech, he is being feted by the House and Senate foreign relations committees and a lawmakers' India Caucus.

Both sides emphasize that the story of the last few years has been one of constructive progress and shared priorities. That's a function of China's rise, the threat of terrorism and the Obama administration's decision to focus resources and attention on Asia. It also reflects the both leaders' recognition that their countries will benefit from closer alignment.

Numbers back the narrative. U.S.-India trade has soared from $60 billion in 2009 to $107 billion in 2015, while American defense contractors are now selling India $14 billion worth of equipment, an increase from $300 million less than a decade ago.

Photos: President Obama visits India Photos: President Obama visits India U.S. President Barack Obama and first lady Michelle Obama fold their hands together in a traditional Indian greeting gesture as they prepare to board Air Force One to depart New Delhi on Tuesday, January 27. Hide Caption 1 of 20 Photos: President Obama visits India Obama greets guests after speaking on U.S.-India relations during a town hall event at Siri Fort Auditorium in New Delhi on January 27. Hide Caption 2 of 20 Photos: President Obama visits India Guests use cell phones to record Obama as he speaks at the town hall event on January 27. Hide Caption 3 of 20 Photos: President Obama visits India Obama speaks at Siri Fort Auditorium in New Delhi on January 27. Hide Caption 4 of 20 Photos: President Obama visits India The Obamas meet with Kailash Satyarthi, third from right, and his family in New Delhi on January 27. Satyarthi, a children's rights advocate, shared the 2014 Nobel Peace Prize with Malala Yousafzai. Hide Caption 5 of 20 Photos: President Obama visits India Indian Prime Minister Narendra Modi, left, and Obama participate in the India-U.S. Business Summit in New Delhi on Monday, January 26. Hide Caption 6 of 20 Photos: President Obama visits India Obama waves to the crowd as he walks with Modi, left, and first lady Michelle Obama after the annual Republic Day parade in New Delhi on January 26. Hide Caption 7 of 20 Photos: President Obama visits India Modi talks with Obama as they watch jets fly overhead during the Republic Day parade on January 26. Hide Caption 8 of 20 Photos: President Obama visits India Indian soldiers march in formation down Rajpath Boulevard during the Republic Day parade on January 26. Hide Caption 9 of 20 Photos: President Obama visits India Obama waves as he arrives at the Republic Day parade on January 26. Hide Caption 10 of 20 Photos: President Obama visits India Obama greets actor Kal Penn at a receiving line before a state dinner at Rashtrapati Bhawan, the presidential palace in New Delhi, on Sunday, January 25. Hide Caption 11 of 20 Photos: President Obama visits India U.S. Rep. Nancy Pelosi, the House minority leader, arrives for the state dinner in New Delhi on January 25. Hide Caption 12 of 20 Photos: President Obama visits India Obama and Modi sit down for tea after a stroll in the gardens of Hyderabad House on January 25. Hide Caption 13 of 20 Photos: President Obama visits India Obama and Modi walk in the gardens of the Hyderabad House. Hide Caption 14 of 20 Photos: President Obama visits India Obama and Modi hug after they jointly addressed the media. Hide Caption 15 of 20 Photos: President Obama visits India Obama and Modi walk into Hyderabad House for a meeting. Hide Caption 16 of 20 Photos: President Obama visits India Obama participates in a tree planting ceremony at Raj Ghat, the Mahatma Gandhi Memorial. Hide Caption 17 of 20 Photos: President Obama visits India Obama offers a floral tribute at the site where Indian independence icon Mahatma Gandhi was cremated in New Delhi. Hide Caption 18 of 20 Photos: President Obama visits India Modi hugs Obama after Obama's arrival in New Delhi. Hide Caption 19 of 20 Photos: President Obama visits India Obama shakes hands with Modi as first lady Michelle Obama stands beside them upon arrival at the Palam Air Force Station in New Delhi. Hide Caption 20 of 20

Defense and security cooperation in particular are "an area of extraordinary progress and ambition in both countries," Assistant Secretary of State for South and Central Asian Affairs Nisha Biswal told a Senate committee in May. She said the two countries' military exercises had grown in scope and complexity. Unspoken but implicit was the fact that they've grown more important, too.

As China increasingly takes steps to establish claims to contested areas in the South China Sea -- through which about half the world's merchant ships sail -- the U.S. has been placing increasing emphasis on the need to maintain freedom of navigation.

"India has an important role to play as a net security provider and guarantor of an open and rules-based maritime order across the Indo-Pacific," Biswal said.

Modi made clear that India is more than ready to do that. "India is already assuming responsibilities in securing the India Ocean region," he said. "A strong India-U.S. partnership can ensure peace prosperity and stability from Asia to Africa and from Indian Ocean to the Pacific," he said.

In an indirect reference to China, he also touted his country's "respect for global commons and for international rules and norms."

China spurs U.S.-India ties

The forces drawing India and the U.S. together go beyond China, though. Both countries see a destabilized Afghanistan and terrorism in Pakistan and beyond as sources of concern. Kugelman says that increasing U.S. impatience with Pakistan's tolerance for certain militant groups also benefits ties between the U.S. and India, which views the Muslim country on its border as its biggest foe.

Pointing to the U.S. drone strike inside Pakistan that killed Taliban leader Mullah Mansour, Kugelman said, "I think what we're seeing in the last few months is the case of the U.S. losing patience with Pakistan."

Modi touched those bases, too, speaking of the need to stabilize Afghanistan and going after India's rival and neighbor, though not by name. He told lawmakers that terrorism is "incubated in India's neighborhood."

He urged greater U.S.-India counterterrorism cooperation and "greater isolation for those who harbor, support and sponsor terrorists."

JUST WATCHED Taliban confirm leader killed in U.S. airstrike Replay More Videos ... MUST WATCH Taliban confirm leader killed in U.S. airstrike 02:06

He points to the close ties between Pakistan and China as another factor. "The Obama administration is very intent on completing this rebalancing to Asia," Kugelman said. "That entails a very significant role for India, and there's simply no role for Pakistan because Pakistan is a very big ally of China."

As a result of all this, "suddenly India begins to look like a better partner for the U.S., and the U.S. looks like an invaluable partner for India," said Sadanand Dhume, an American Enterprise Institute expert on India.

Under the tenure of Obama and Modi, that dynamic has been turbo-charged. Obama has made two visits to India, the most by any sitting president. Obama has backed India's inclusion on the UN Security Council and in multilateral export control regimes, said Singh, who noted advances made in defense, trade and economic partnerships as well.

Meanwhile, Modi's current visit marks his seventh meeting with Obama in the U.S. and abroad.

India reorients

Over the course of those visits, the Indian leader has made a deliberate shift, said Dhume. "What Modi has done is made clear that a large country with a tradition of non-alignment is, under this prime minister, moving decisively toward a deeper relationship with the U.S.," Dhume said.

India had historically allied itself with the Soviet Union and then Russia, along with Brazil and China, as part of a group of countries that wanted to stay out of the U.S. orbit.

The bilateral relationship has gotten an extra boost from the chemistry the two leaders share. Raymond Vickery, who worked on U.S.-India trade as an assistant secretary of commerce under President Bill Clinton, attributed its roots to their similar backgrounds.

"Both Obama and Modi have spent most of their lives as outsiders," said Vickery, a global fellow at the Wilson Center. "They've both come to power with a common vision of being able to have a U.S.-India relationship that's worldwide in scope."

U.S.-India ties aren't dependent on personal chemistry, though, Dhume said. The long, slow deepening links between the two countries is about "the importance of India, much more than the importance of Modi," he said, referring to its strong economy, positive trade and defense relationships and its status as a democratic model for the region and counterweight to China.

"India matters, no matter who is the leader," Dhume said.