NEW DELHI — The United States and India signed an agreement Thursday to pave the way for New Delhi to buy advanced American weaponry and to share sensitive military technology, strengthening their military partnership as both powers warily eye the rise of China.

“Today’s fruitful discussion illustrated the value of continued cooperation between the world’s two largest democracies,” said Jim Mattis, the United States defense secretary, at a news conference on Thursday after the agreement was signed. “We will work together for a free and prosperous Indo-Pacific.”

The countries also promised to hold joint land, sea and air military exercises in India next year. In the past, they have held joint exercises outside the country.

But despite the friendly handshakes and flattering remarks exchanged as Mr. Mattis and Mike Pompeo, the secretary of state, met with their counterparts in New Delhi on Wednesday and Thursday, the two countries remain deeply skeptical of each other.