Activists of India's Hindu nationalist Shiv Sena party carry an effigy of Pakistan Prime Minister Nawaz Sharif during a protest in New Delhi. (Tsering Topgyal/AP)

Pakistan’s prime minister has been preparing for days to make a forceful appearance at the U.N. General Assembly on Wednesday, hoping to burnish his international credentials with a ringing denunciation of Indian aggression in the disputed border region of Kashmir.

But on Sunday, militants killed 17 Indian troops at an army base in the Indian-controlled portion of Kashmir, the deadliest such attack in more than a decade. Another soldier died Monday, raising the death toll to 18. The assault instantly shifted the political scales — with some officials in New Delhi reviving accusations of Pakistan supporting terrorist groups.

By Monday, Islamabad was back on the offensive. Officials adamantly denied any involvement and excoriated India for making what they called unsubstantiated and “premature” charges.

It adds up to a messy backdrop for Pakistan’s prime minister, Nawaz Sharif, who planned to use the annual U.N. gathering to raise issues over Kashmir, where both nations have faced off for decades and which remains a major point of friction between the regional powers.

Pakistani officials also expected Sharif to hold separate talks with President Obama in New York.

The territorial dispute over the Himalayan region has long dominated the rivalry between Pakistan and India, which have fought three wars, and has persisted despite numerous failed attempts at negotiation.

Since the 1990s, both civilian opposition and armed rebellion have repeatedly erupted in Indian Kashmir, with Muslim groups seeking various degrees of autonomy from the government of predominately Hindu India.

India has long accused Pakistan of arming and sheltering the militants, while Pakistan has always insisted that it provides only moral support to their cause and has accused India of military repression.

“Pakistan categorically rejects the baseless and irresponsible accusations being leveled” by Indian officials, Pakistan’s senior foreign policy adviser, Sartaj Aziz, said in a statement from New York. He said India was attempting to “deflect attention from the fast deteriorating humanitarian and human rights situation in Indian-occupied Kashmir” and to “cover up India’s reign of terror.”

In New Delhi, Prime Minister Narendra Modi met with military advisers and national security officials, planning what Lt. Gen. Ranbir Singh, director general of military operations, said would be a “befitting reply” to the attack.

“We have the desired capability to reply to such [a] blatant act of violence in a manner as deemed appropriate by us,” Singh said in a news conference Monday, without giving further details.

Options included shelling Pakistani posts near the de facto border with India or waging crackdowns on local militants, some analysts speculated.

Diplomatic fallout, meanwhile, could include India cutting off all talks or refusing to attend a South Asian summit in Islamabad later this year.

“Much will depend on how much Modi wants to stake his entire political capital on this. My sense is the response will not be impulsive,” said C. Uday Bhaskar, a military analyst and the director of the Society for Policy Studies in New Delhi. “But he’s under enormous pressure to do something.”

Meanwhile in Srinagar, the Kashmir Valley city that has been a flash point for Muslim unrest, Indian officials held a ceremony placing wreaths on the flag-draped coffins of the soldiers killed Sunday after four militants armed with grenades and assault rifles allegedly attacked a military post in the town of Uri. Officials said several others remained hospitalized with burns and other injuries.

The valley has been roiled by near-daily protests since early July, when Burhan Wani, a popular commander of the Kashmiri militant group Hizbul Mujahideen, was killed in a confrontation with Indian forces. More than 70 people have since died in clashes between stone-pelting youths and Indian security forces, and hundreds more have been blinded or injured by military pellet guns.

Pakistan’s army chief, Gen. Raheel Sharif, said in a statement that Pakistan had noted India’s “hostile narrative” of the incident and that “the armed forces of Pakistan are fully prepared to respond to the entire spectrum of direct and indirect threats.”

“This single attack and this single day has tilted the balance in favor of India,” said Amir Rana, a security analyst in Islamabad. “Earlier, it was all talk about Indian human rights violations. Now it will be overshadowed by terrorism.”

Sharif, he said, “won’t have the confidence he had before the attack. This has weakened Pakistan’s moral and diplomatic position.”

Pakistani officials insisted Monday that they maintain an “airtight lock” of surveillance and barriers at the “line of control” separating the two sides. India said at least three of the Sunday attackers had crossed the line.

Last month, when Secretary of State John F. Kerry made a high-profile visit to India, officials there complained to him about cross-border terrorism from Pakistan, including the 2008 rampage in Mumbai that killed 164 people and was carried out by the Pakistan-based terrorist group Lashkar-e-Taiba. Kerry responded that Washington “stands with India on all matters of terrorism, no matter where it comes from. . . . We cannot and will not distinguish between good terrorists and bad terrorists.”

Pakistan, in turn, has accused India of fomenting cross-border violence.

In August, when suicide bombers killed 70 people in Quetta, a remote Pakistani city in Baluchistan province near the Afghan border, Pakistani officials charged that India’s intelligence agency was behind the attack, although it was claimed by two separate Islamist militant groups operating in Pakistan and Afghanistan.

A week later, in a speech on India’s independence day, Modi referred to alleged Pakistani human rights abuses taking place in Baluchistan.

Pakistan, a onetime Cold War ally of the United States, has maintained close security ties with Washington in the war against Islamist terrorism. But it is also alarmed by growing U.S. ties with India under Modi, a lifelong pro-Hindu activist, and about India’s deepening relationship with Afghanistan, whose U.S.-backed government has also accused Pakistan of harboring violent militant groups.

“Pakistan and India are back to the traditional war of words, and I can’t see any chance of a resumption of peace talks between them in the near future,” said Hasan Askari Rizvi, a defense analyst based in Lahore, Pakistan. “As long as Prime Minister Modi is in power, it doesn’t seem possible.”

Gowen reported from New Delhi. Shaiq Hussain in Islamabad contributed to this report.