The sparring between India and Pakistan last month threatened to spiral out of control and only interventions by US officials, including National Security Advisor John Bolton, headed off a bigger conflict, five sources familiar with the events said.
At one stage, India threatened to fire at least six missiles at Pakistan, and Islamabad said it would respond with its own missile strikes "three times over", according to Western diplomats and government sources in New Delhi, Islamabad and Washington.
The way in which tensions suddenly worsened and threatened to trigger a war between the nuclear-armed nations shows how the Kashmir region, which both claim and is at the core of their enmity, remains one of the world's most dangerous flashpoints.
The exchanges did not get beyond threats, and there was no suggestion that the missiles involved were anything more than conventional weapons, but they created consternation in official circles in Washington, Beijing and London.
Reuters has pieced together the events that led to the most serious military crisis in South Asia since 2008, as well as the concerted diplomatic efforts to get both sides to back down.
The simmering dispute erupted into conflict late last month when Indian and Pakistani warplanes engaged in a dogfight over Kashmir on Feb 27, a day after a raid by Indian jet fighters on what it said was a militant camp in Pakistan.
Islamabad denied any militant camp exists in the area and said the Indian bombs exploded on an empty hillside.
In their first such clash since the last war between the two nations in 1971, Pakistan downed an Indian plane and captured its pilot after he ejected in Pakistan-controlled Kashmir.
Hours later, videos of the bloodied Indian pilot, handcuffed and blindfolded, appeared on social media, identifying himself to Pakistani interrogators, deepening anger in New Delhi.
With Prime Minister Narendra Modi facing a general election in April-May, the government was under pressure to respond.
"NO GOING BACK"
That evening, Indian National Security Adviser Ajit Doval spoke over a secure line to the head of Pakistan's Inter Services Intelligence (ISI), Asim Munir, to tell him India was not going to back off its new campaign of "counter terrorism"even after the pilot's capture, an Indian government source and a Western diplomat with knowledge of the conversations told Reuters in New Delhi.
Doval told Munir that India's fight was with the militant groups that freely operated from Pakistani soil and it was prepared to escalate, said the government source.
A Pakistani government minister and a Western diplomat in Islamabad separately confirmed a specific Indian threat to use six missiles on targets inside Pakistan.
They did not specify who delivered the threat or who received it, but the minister said Indian and Pakistani intelligence agencies "were communicating with each other during the fight, and even now they are communicating with each other".
Pakistan said it would counter any Indian missile attacks with many more launches of its own, the minister told Reuters, speaking on condition of anonymity.
"We said if you will fire one missile, we will fire three. Whatever India will do, we will respond three times to that,"the Pakistani minister said.
Doval's office did not respond to a request for comment. India was not aware of any missile threat issued to Pakistan, a government official said in reply to a Reuters request for comment.
Pakistan's military declined to comment and Munir could not be reached for comment. Pakistan's foreign ministry did not respond to a Reuters request for comment.
The crisis unfolded as US President Donald Trump was trying to hammer out an agreement with North Korean leader Kim Jong Un in Hanoi over its nuclear programme.
US security advisor Bolton was on the phone with Doval on the night of Feb 27 itself, and into the early hours of Feb 28, the second day of the Trump-Kim talks, in an attempt to defuse the situation, the Western diplomat in New Delhi and the Indian official said.
Later, US Secretary of State Mike Pompeo, who was also in Hanoi, also called both sides to seek a way out of the crisis.
"Secretary Pompeo led diplomatic engagement directly, and that played an essential role in de-escalating the tensions between the two sides," State Department deputy spokesperson Robert Palladino said in a briefing in Washington on March 5.
A State Department official declined comment when asked if they knew of the threats to use missiles.
Pompeo spoke to Doval, the Indian and Pakistani Foreign Ministers Sushma Swaraj and Shah Mahmood Qureshi, respectively, Palladino said.
US Indo-Pacific Command Admiral Phil Davidson told reporters in Singapore last week that he had separately been in touch with the Indian navy chief, Sunil Lanba, throughout the crisis.
There was no immediate response from Lanba's office to a question on the nature of the conversations.
US efforts were focused on securing the quick release of the Indian pilot by Pakistan and winning an assurance from India it would pull back from the threat to fire rockets, the Western diplomat in New Delhi and officials in Washington said.
"We made a lot of effort to get the international community involved in encouraging the two sides to de-escalate the situation because we fully realised how dangerous it was," said a senior Trump administration official.
The Pakistani minister said China and the United Arab Emirates also intervened. China's foreign ministry did not respond to requests for comment. The government of the UAE said Abu Dhabi Crown Prince Sheikh Mohammed bin Zayed al-Nahyan held talks with both Modi and Pakistan Prime Minister Imran Khan.
India has not given details, but has said it was in touch with major powers during the conflict.
On the morning of Feb 28, Trump told reporters in Hanoi that he expected the crisis to end soon.
"They have been going at it and we have been involved in trying to have them stop. Hopefully that is going to be coming to an end."
Later that afternoon, Khan announced in Pakistan's parliament that the Indian pilot would be released, and he was sent back the next day.
"I know last night there was a threat there could a missile attack on Pakistan, which got defused," Khan said. "I know, our army stood prepared for retaliation of that attack."
The two countries have gone to war three times since both gained independence in 1947, the last time in 1971. The two armies are trading fire along the line of control that separates them in Kashmir, but the tensions appear contained for now.
Diplomatic experts said that the latest crisis underlined the chances of misread signals and unpredictability in the ties between the nuclear-armed rivals, and the huge dangers.
It still was not clear whether India had targeted a militant camp in Pakistan and whether there were any casualties, they said.
"Indian and Pakistani leaders have long evinced confidence that they can understand each other's deterrence signals and can de-escalate at will," said Joshua White, a former White House official who is now at Johns Hopkins.
"The fact that some of the most basic facts, intentions and attempted strategic signals of this crisis are still shrouded in mystery ... should be a sobering reminder that neither country is in a position to easily control a crisis once it begins."