China and India have reached an agreement to end a 20-day standoff over an alleged incursion by Chinese troops far into Indian territory in the disputed Ladakh region of eastern Kashmir.

"China and India have reached an agreement on resolving the incident in the western section of the border. The frontier forces of the two countries have terminated the standoff at the Tiannan River Valley area," Chinese foreign ministry spokeswoman Hua Chunying said.

The two Asian giants agreed to pull back troops to the positions held before the dispute on the Himalayan border erupted in April.

It flared up after a platoon of Chinese soldiers allegedly crossed the de facto boundary between the two nations and pitched tents 10km inside Indian territory. China publicly denied the crossing ever happened and dismissed the claims as media speculation.

But the case stirred up tensions in India as Ladakh remains a sensitive issue since Delhi's troops were crushed in the 1962 war with China.

New Delhi summoned Beijing's ambassador to lodge a complaint about the latest incursion and pushed soldiers up to the front line just 300 metres from chinese troops.

Local army commanders held several unsuccessful rounds of talks and the incident was threatening to sabotage scheduled reciprocal visits by India's foreign minister Salman Khurshid to China and Chinese Premier Li Keqiang's to Delhi.

China has recently become India's biggest trading partner. Two-way trade jumped from $5bn in 2002 to nearly $75bn in 2011, but declined slightly last year in the wake of the global economic crisis.

Hua said maintaining peace in the border areas works was in the common interests of the two countries, Xinhua news agency reported, and urged Delhi to work with Beijing to reach "a fair, reasonable and mutually acceptable resolution to border issues".

India claims that China occupies 38,000 sq km (15,000 square miles) of territory in the Aksai Chin plateau in the western Himalayas, while China says that 90,000 sq km of land in India's northeastern state of Arunachal Pradesh belong to Beijing.