Deputy Secretary of State Richard L. Armitage eased into his chair in the spacious villa of the Pakistani president with one critical objective: What sort of concession could he bring to India the next day that would erase the threat of a potential nuclear war between the longtime South Asia rivals?

Armitage had war-gamed his strategy with key advisers in the days before he landed in Islamabad on June 6. His boss and close friend, Secretary of State Colin L. Powell, had paved the way with 11 phone calls to President Pervez Musharraf over two months, as the tensions over the disputed Kashmir area had flared up and the two countries mobilized a million troops. President Bush had weighed in with his own calls, including one the day before.

A veteran diplomat with a blunt manner, Armitage spent the next two hours gently probing Musharraf, asking, "What can I tell the Indians?" Musharraf had already pledged to halt terrorist infiltrations in the Indian-held part of Kashmir. Armitage wanted to go a step further: Would Musharraf now promise a "permanent end" to the terrorist activity long encouraged by Pakistan?

"Yes," Musharraf replied.

The Armitage-Musharraf agreement, which was described by U.S. and Pakistani officials in recent interviews, proved to be a defining moment in weeks of frantic diplomacy by the U.S. and its allies to pull two proud nations from the brink of a devastating nuclear exchange. Musharraf's decision to agree to the word "permanent" -- backed by U.S. assurances to India that he would keep his word -- immediately led India to take steps to ease tensions.

The meeting could have long-term implications. Terrorist attacks in Kashmir have repeatedly drawn India and Pakistan into conflict, and if Pakistan's tacit support for the insurgents dries up, it could lead to a new relationship between two nations long divided by religion and a bloody, tense history.

While the general outlines of the U.S. effort to defuse the conflict have been known, few details of the diplomatic effort have emerged until now. In part, that's because tensions are still at a slow boil and the next stage of U.S. involvement has not been determined, making many U.S. officials reluctant to discuss their diplomacy.

"We had a choice," said Dennis Kux, a former State Department official who has written histories of U.S. relations with Pakistan and India. "We could sit on our hands or we could slam the Pakistanis. And we did, hard but politely."

Indeed, Musharraf's concession amounted to a huge foreign-policy victory for India, which for a decade had sought an end to the terrorist attacks. Indian officials were so stunned by Armitage's report on his meeting with Musharraf that they had trouble believing it at first, Bush administration officials said.

But India's decision to press to the military brink came with a price, because U.S. officials -- including President Bush the day before Armitage arrived in Islamabad -- also gave Musharraf private assurances that they would finally focus on ways to resolve the half-century dispute over Kashmir.

"We told him we want to stay involved," one official said.

In early May, the State Department had already privately decided to send Armitage to the region as part of diplomatic efforts to head off the crisis. But while Assistant Secretary of State Christina B. Rocca was visiting New Delhi, insurgents killed 30 people, including women and children, in India-controlled Kashmir.

The attack suddenly sent the two nations on a war-footing, leading to widespread speculation that the world was facing its tensest nuclear confrontation since the Cuban Missile crisis in 1962. Even before both sides had acquired nuclear weapons, India and Pakistan had fought three wars over Kashmir since the two countries were founded in 1947 and India absorbed the Muslim-majority state over Pakistan's objections.

Indian Prime Minister Atal Bihari Vajpayee visited troops near the front and spoke of a "decisive victory." Musharraf scheduled provocative tests of missiles that could carry nuclear warheads.

In many ways, the Indians were testing the limits of the Bush administration's rhetoric in the war on terrorism. Officials have striven to reward Musharraf for his dramatic decision to abandon the Taliban after Sept. 11 and support U.S. military intervention in Afghanistan, even while he quietly allowed terrorist activity to resume once the snows melted in the Kashmir region this spring.

Since President Bush never made a distinction between all terrorists and simply al Qaeda, Indian officials -- much like Israelis and the Russians -- decided to force the United States to choose sides in a conflict that only one side labeled terrorism. Ultimately, the United States had to clamp down on Pakistan's continuing support for jihadist groups in Kashmir, even though many officials also believe India long has thwarted Kashmiri political ambitions.

Within the administration, White House national security adviser Condoleezza Rice mostly handled the India account, speaking regularly to her Indian counterpart, Brajesh Mishra. Powell also spoke a few times to the Indian foreign minister, Jaswant Singh, but he was primarily responsible for working Musharraf. In one two-week period in May, Powell spoke to Musharraf five times, according to State Department records.

Powell had formed a bond with Musharraf, a fellow general, who has charmed U.S. officials with a quietly impressive manner. At a dinner in November, for instance, Musharraf -- who seized power in a 1999 coup -- captivated Bush during a detailed conversation on education reform. And in January, with Powell's urging, Musharraf had made a speech forcefully declaring his opposition to terrorism and Islamic extremism.

But now the relationship had come under strain. Musharraf had gone ahead with a controversial referendum on his leadership, which had weakened him domestically, and the United States had information that Pakistan, especially its intelligence agency, was still linked to terrorist groups in Kashmir. Musharraf also had released hundreds of extremists that had been rounded up after the January speech.

Within Pakistan, Musharraf has struggled not to be seen as weak on Kashmir, since any perceived loss to India would devastate him politically. In fact, in Musharraf's speech explaining his decision to join the U.S. alliance after Sept. 11, he cited Kashmir as a reason, saying it "could be endangered if we make the wrong decisions now."

Powell, in his phone calls, pressed Musharraf to put a stop to infiltrations over the "Line of Control," the tense de facto border between India and Pakistan in the Kashmir highlands.

While the administration decided to tilt toward India in the crisis, officials also ratcheted up pressure on Pakistan's neighbor by issuing a travel advisory warning Americans to avoid traveling to India and suggesting diplomatic personnel consider leaving. Countries around the globe followed suit, chilling Indian business investment and trade.

On June 5, in what Pakistani officials consider a key commitment, Bush called Musharraf to emphasize the United States would stay engaged to resolve the Kashmir conflict.

In essence, U.S. officials were pressing an unusual diplomatic gambit, which Stephen P. Cohen, a South Asia specialist at the Brookings Institution, labeled "parallel bilateralism."

With the India and Pakistan unable or unwilling to resolve the conflict themselves, the United States decided to step in forcefully to change Pakistan's behavior while at the same time vouching for Pakistan to the Indians. That left India little choice but to accept U.S. assurances and begin to take steps to reduce its military posture. It was also politically easier for Musharraf to accede to U.S. pressure than Indian saber-rattling.

The stage thus was set for a deal when Armitage arrived on the morning of June 6, a hot and windy day, at the Chief Executive's Office, once the residence of Pakistan's elected prime ministers, in a room with views over Islamabad's Margalla Hills. The conversation, according to officials in both governments, was relaxed and comfortable.

Armitage told Musharraf that the U.S. was aware that Musharraf had ordered an end to the infiltrations, and the U.S. had concluded the cross-border activity had abated. He said he would share this assessment with the Indians when he arrived in New Delhi. But he wanted to know what else he could bring.

Once Musharraf agreed to the term "permanent," Armitage reconfirmed several times over the two-hour conversation that Musharraf was comfortable with it, and that he could relay this commitment to India, officials said.

Musharraf then raised his own point -- that an early and substantial response from the Indian side "will make what I am doing sustainable." Armitage agreed that was a reasonable position and that he would convey that to the Indian government.

In India, which has a thriving and complex democracy, the response "was touch and go for a while," an administration official said. As Armitage and his team briefed the Indian leadership, the response was often fairly skeptical. Many said Musharraf could not be trusted, but they ultimately conceded that if the United States was vouching for him, they had to respond.

"If Pakistan had not agreed to end infiltration, and America had not conveyed that guarantee to India, then war would not have been averted," Indian Prime Minister Vajpayee told an Indian newspaper last week.

Within days, before what amounted to a mop-up visit by Defense Secretary Donald H. Rumsfeld, India had taken steps to signal the response sought by Musharraf, including allowing commercial overflights, moving fleets back to their home bases and preparing to name a high commissioner for Pakistan. Indian officials said last week the border crossings appear to have ended.

Still, tensions are still high enough that U.S. officials are wary of proclaiming victory. The risk is that Musharraf, despite his pledge, is unable or unwilling to reign in the jihadist insurgents in Kashmir; the plight of the Kashmiri people is often used by Pakistani politicians to whip up nationalist fervor. India, meanwhile, has long resisted any international efforts to resolve the Kashmir dispute, insisting it is strictly a regional issue. Greater autonomy or independence for Kashmir, some argue, could lead to the breakup of the multiethnic state.

Officials say this makes the next step even more critical. Powell is urging his staff to think of creative ways to encourage a dialogue between India and Pakistan which would ultimately lead to a readjustment of the status of Kashmir.

Officials believe such an outcome would strengthen Musharraf's position and reward him for continuing to accommodate U.S. demands. It also would help India to finally emerge as a great power, an assessment officials believe the Indians privately share.

"The Indians know they have to do something politically in Kashmir," one official said.

Deputy Secretary of State Richard L. Armitage played key diplomatic role.Pakistani President Pervez Musharraf, left, meets with U.S. Deputy Secretary of State Richard L. Armitage in Islamabad on June 6.