For three days, Pakistan watched as President Obama and Indian Prime Minister Narendra Modi pledged closer cooperation on defense, economic and civilian nuclear issues, and Obama repeatedly endorsed India's bid for a permanent United Nations Security Council seat.
Hours after the president departed New Delhi, the government in Islamabad lambasted the United States on Tuesday for "selectivity and discrimination" favoring rival India, the first sign of how Obama's diplomatic outreach could upset old alliances in the region.
"Pakistan values its relations with the United States and expects it to play a constructive role for strategic stability and balance in South Asia," Pakistan's Foreign Ministry said in a statement.
The comments reflected deep concern in Pakistan that Obama's heavily choreographed embrace of India and its ambitious new prime minister could jeopardize Islamabad's lucrative but troubled relationship with Washington.
During Obama's trip, the U.S. and India issued a statement calling on Pakistan to crack down on militants and bring the perpetrators of the 2008 terrorist attacks in Mumbai, India's commercial hub, to justice.
In one-on-one meetings, aides say, Obama and Modi shared worries over the growing clout of China, one of Pakistan's main patrons, and signaled closer cooperation in Afghanistan as U.S.-led coalition forces depart, imperiling Pakistan's years-long effort to maintain a strategic foothold there.
In response, Pakistan said that U.S. plans to provide India with civilian nuclear technology, meant to reduce India's use of fossil fuels, "would have a detrimental impact on deterrence stability in South Asia." The statement also said India "by no means qualifies for a special status in the Security Council," citing breaches of U.N. resolutions in Kashmir, the disputed region claimed by both countries.
Pakistani news media covered Obama's visit extensively, noting that it was his second trip to India as president but that he has not visited Pakistan since taking office.
U.S. officials say they continue to view Pakistan as a crucial partner in counter-terrorism efforts. Obama is concerned about extremists operating with impunity in Pakistan's northern tribal regions, aides said, largely because of the potential for attacks against the 13,000 American troops remaining in Afghanistan.
In Islamabad this month, Secretary of State John F. Kerry praised the Pakistani army's ongoing offensive against militants in the tribal areas, calling it "a major initiative."
"Frankly, we believe that that relationship is on the uptick," deputy national security advisor Ben Rhodes said of Pakistan. "It's as good as it's been in years, and so we feel confident in our high-level engagement."
But in pointed comments before his trip, Obama told India Today magazine, "I've made it clear that even as the United States works with Pakistan to meet the threat of terrorism, safe havens within Pakistan are not acceptable and that those behind the Mumbai terrorist attack must face justice."
Pakistan's Foreign Ministry said it "rejects any insinuation or aspersion over its commitment to fight terrorism."
After the Sept. 11 terrorist attacks in the United States, Washington channeled billions of dollars in military and economic assistance to Pakistan to help fight terrorism, an alliance that was one of many hurdles in the U.S.-India relationship. However, Pakistan's commitment to the fight has long been questioned, most notably after U.S. forces found Osama bin Laden living outside Islamabad and killed the Al Qaeda leader in May 2011.
That prompted the White House to scrap plans for Obama to visit Pakistan that year.
In November, shortly after the India trip was announced, Obama reportedly called Pakistani Prime Minister Nawaz Sharif to discuss it, a move that did not mollify Pakistani officials.
"Pakistan is an important country of the region and world," said Muhammad Mehdi, a foreign affairs analyst in Lahore. "It has a relationship with the U.S. for decades, and informing the prime minister just on the phone is not enough."
The White House had not considered adding other countries to Obama's itinerary and decided only at the last moment to go to Saudi Arabia to pay respects to the family of the late king.
"We don't view these relationships [with India and Pakistan] as taking place at the expense of the other," Rhodes said. "We can have a good relationship with India and we can have a good relationship with Pakistan. And that's in the interest of all three."
Relations between India and Pakistan — blood enemies who were split upon independence from Britain in 1947 — are at perhaps their lowest point since the aftermath of the 2008 Mumbai attacks, which were carried out by Pakistan-based militants. Several suspects are in custody, but their trial has been beset by delays.
The suspected mastermind of the attacks was granted bail last month, fueling outrage in India until he was ordered back into custody until Feb. 18.
Last year, a bid to restart negotiations on the countries' disputed border was called off after India objected to a meeting between a Pakistani envoy and an Indian Kashmiri separatist group. The rival armies have since exchanged fire multiple times across the boundary, causing thousands to flee their homes.
The killing of scores of schoolchildren by the Pakistani Taliban in Peshawar last month underscored concern about Pakistan's inability to rein in militant groups.
After the attack, Pakistan said it would take action against all insurgent groups on its soil. Last week, Pakistani officials said they had banned a major anti-India militant group, Jamaat-ud-Dawa, whose leader, Hafiz Saeed, is wanted by the United States in connection with the Mumbai attacks.
But on Sunday, as Obama landed in New Delhi, Saeed held a large rally in the Pakistani port city of Karachi and railed against both the U.S. and India, which he called "the terrorist's disciple."
The Pakistani military has also quietly stepped up accusations against India. The army presented evidence to the U.S. that Indian intelligence operatives are supporting antigovernment militants in Pakistan, defense officials told Pakistani lawmakers Monday.
Mian Khursheed Mehmood Kasuri, a former Pakistani foreign minister, said that although Obama's trip had a "psychological" effect, the U.S. could not abandon Pakistan.
"Afghanistan is of prime importance for the U.S.," Kasuri said. "They would not want Afghanistan to become another Iraq after they withdraw. They need Pakistan's army and intelligence. This cannot be overlooked."
Times staff writers Bengali and Parsons reported from New Delhi and special correspondent Sahi from Islamabad, Pakikstan.