A crisis of unprecedented scale, the Doklam standoff which ran for about two-and-a-half months, ended on time today before it could embarrass the leadership of both India and China at the BRICS summit which Prime Minister Narendra Modi is expected to attend.

The 9th annual BRICS summit will take place in China's Xiamen on September 3-5.

According to top government sources, the discussion on the breakthrough started when the National Security Advisor Ajit Doval met his Chinese counterpart, State Councillor Yang Jiechi, in Beijing during the BRICS meeting in July 27-28.

The parleys continued between the two NSAs quietly away from the public glare over telephone lines along with diplomatic efforts to resolve the crisis.

Chinese President Xi Jinping and PM Modi had decided that NSA Doval and his Chinese counterpart Yang Jiechi would talk to defuse the tension. The NSA and his equivalent met and had a long meet in Hamburg.

Further movement happened during the Beijing meeting. Foreign Secretary Jaishankar and Indian Ambassador to Beijing Vijay Gokhale took the issue forward.

Today Modi who had pushed the be diplomatic but stand firm line received a final briefing before the withdrawal order from Doval.

Official Spokesperson's response to questions on the Doklam disengagement understanding pic.twitter.com/we1vFIIBfh - Raveesh Kumar (@MEAIndia) August 28, 2017

Withdrawal began after flag meeting between 2 colonels of Indian and Chinese army this morning.

Flag meeting will be held in few days to decide on withdrawing from other positions India and China are occupying, according to sources.

After Doklam, Yatung and Phari Dzong are to be cleared after further discussion.

Now the Chinese have agreed to not build the road further in the Doklam area and withdraw its troops from there.

Troops of India and China were locked in a bitter standoff in Dokalam since June 16 after Indian troops stopped the Chinese army from building a road in the disputed area.

It also appears that the Indian side also made PM Modi's visit to the BRICS summit conditional as India wanted to resolve the issue.

Indian Army's tough stand in the standoff also helped in putting pressure on China which was made to understand that India will not back off so easily without its demands being accepted.

The Chinese have now agreed to completely withdraw their troops from the area.

MEA Press Statement on Doklam Disengagement Understanding pic.twitter.com/fVo4N0eaf8 ; Raveesh Kumar (@MEAIndia) August 28, 2017

This is being termed as major victory of Modi's national security team including both civilian and military diplomacy.

External Affairs Minister Sushma Swaraj recently said both sides should first pull back their troops for any talks to take place, and favoured a peaceful resolution of the border standoff.

Relations between the two nations had dipped to a new low over the standoff at Doklam, with the Chinese side refusing to withdraw. Beijing had accused India of transgressing into its territory and demanded immediate withdrawal of Indian troops. The Chinese side, especially the state media, since then had been on an offensive, and on occasions issued veiled threats of war.

India has maintained that both sides should withdraw simultaneously for any dialogue on the issue, and asserted that war was not a solution.

Also read:

Doklam standoff ends: What made China agree to restore pre-June 16 position of troops

India-China Doklam border standoff set to end after deal on withdrawing troops

Why Doklam standoff is not good for Chinese President Xi Jinping ahead of BRICS Summit, CPC Congress

Why Japan lent support to India against China over Doklam standoff

ALSO WATCH|

Doklam border standoff set to end after India-China strike deal to withdraw troops