India and China have agreed to an "expeditious disengagement" of troops in a disputed border area where their soldiers have been locked in a stand-off for more than two months, India's foreign ministry said on Monday.
The decision comes ahead of a summit of the BRICS nations - a grouping that also includes Brazil, Russia and South Africa - in China next month, which Indian Prime Minister Narendra Modi is expected to attend.
Indian and Chinese troops have been confronting each other at the Doklam plateau near the borders of India, its ally Bhutan and China, in the most serious and prolonged standoff in decades along their disputed Himalayan border.
The Indian ministry said the two sides had agreed to defuse the crisis following diplomatic talks.
"In recent weeks, India and China have maintained diplomatic communication in respect of the incident at Doklam," the ministry said in a statement.
"On this basis, expeditious disengagement of border personnel at the face-off site at Doklam has been agreed to and is on-going," it said in a statement.
It did not offer more details of the terms of disengagement from the area which had raised fears of a wider conflict between the Asian giants who fought a brief border war in 1962.
China said Indian troops had withdrawn from the remote area in the eastern Himalayas. Chinese foreign ministry spokeswoman Hua Chunying said Chinese troops would continue to patrol the Doklam region.
"China will continue to exercise sovereignty rights to protect territorial sovereignty in accordance with the rules of the historical boundary," she said.
India and China have been unable to settle their 3,500-km (2,175-mile) frontier and large parts of territory are claimed by both sides.
"China hopes India respects the historical boundary and works with China to protect peace along the border on the basis of mutual respect of each other's sovereignty," Hua added.
The trouble started in June when India sent troops to stop China building a road in the Doklam area, which is remote, uninhabited territory claimed by both China and Bhutan.
India said it sent its troops because Chinese military activity there was a threat to the security of its own northeast region.
But China has said India had no role to play in the area and insisted it withdraw unilaterally or face the prospect of an escalation. Chinese state media had warned India of a fate worse than its crushing defeat in the war in 1962.
Indian political commentator Shekhar Gupta said there was too much at stake for the two countries to fight over a small piece of territory.
"Hopefully, Doklam is a new chapter in India-China relations. Too much at stake for both big powers to let legacy real-estate issues linger," he said in a Twitter post.
Small incursions and troop stand-offs are common along other parts of the contested 3,500-km (2,175-mile) frontier, but the recent impasse was marked by its length and the failure of talks to resolve the dispute, raising fears of a wider escalation as the two Asian giants compete for influence.
The Nathu La Pass on the frontier between the Indian state of Sikkim and Chinese-controlled Tibet, was the site of a fierce border clash between Chinese and Indian troops in 1967.