India's Ministry of External Affairs said India and China had diplomatic exchanges in recent weeks over the situation on Doklam plateau in the eastern Himalayas and both had agreed to "go back to the status quo" before the standoff.
Both India and China said their troops would continue to patrol in the Doklam area as they did before the face-off. The breakthrough comes just days before Indian Prime Minister Narendra Modi is to travel to China for a meeting of BRICS leaders next month. The BRICS grouping comprises Brazil, Russia, India, China and South Africa.
In Beijing, foreign ministry spokeswoman Hua Chunying told reporters that Chinese forces in the area had verified the Indian pullout and that China will "continue to exercise its sovereignty and uphold its territorial integrity in accordance with the historical conventions."
Hua said Chinese border troops were continuing to patrol in the area, but made no mention of their road-building activities that had prompted India to send its forces across the border nearly three months ago.
An official of the Indian ministry said his country also planned to verify "in due course of time that Chinese troops have also moved back." "Both sides have acted maturely and have agreed to go back to the status quo," said the official, who spoke on condition of anonymity because he was not authorized to speak to the media.
Analysts hailed the troop pullback, but said after the acrimony of the past months, ties between the neighbors could not be the same. "Both sides realized that this was not an issue on which they needed to have some kind of a shooting match which would completely destroy relations between the two countries," said Sushant Sareen, a senior fellow at the Vivekanand International Foundation, a New Delhi-based think tank.
Sareen said the danger of an accidental exchange of fire had been diffused, but "Does this mean that all is hunky dory between India and China? Certainly not." The confrontation, which began in June when Indian troops moved in to stop China from constructing a road in the Doklam region in Bhutan, was the worst in decades. India had insisted that the impasse would be resolved through diplomatic talks, while China demanded that India withdraw its troops from Doklam before any talks could take place.
Doklam is claimed by the tiny kingdom of Bhutan, but Beijing says it belongs to China based on an 1890 Chinese-British treaty. Bhutan and China have held several rounds of border talks but have not made progress in resolving the dispute.
The area, also popularly referred to by Indians as the "chicken neck," is a narrow corridor that links mainland India with its remote northeastern states. New Delhi's concerns about the Chinese presence in Doklam stemmed from fears that if China was able to block the corridor, it would isolate India's northeast from the rest of the country.
Relations between the two Asian giants have often been strained, partly due to an undemarcated border. China claims some 90,000 square kilometers (35,000 square miles) of territory in India's northeast and cites the region's cultural affinity with Tibet as evidence that the area is part of what it calls "southern" Tibet. India says China occupies 38,000 square kilometers (15,000 square miles) of its territory in the Aksai Chin plateau in the western Himalayas.
Differences also remain over the presence of the Tibetan spiritual leader, the Dalai Lama, who fled China in 1959 during a failed uprising against Chinese rule. The Dalai Lama and the self-proclaimed Tibetan government-in-exile have since been based in the northern Indian town of Dharamsala.
China and India fought a brief war in 1962, leading to fears that the recent row could spiral out of control.
Associated Press writer Chris Bodeen in Beijing contributed to this report.