NEW DELHI — India’s prime minister came under increasing pressure Monday from within his own party, as many in the country demanded a strong response to a deadly weekend attack that the government blames on Pakistan-based militants.

But amid the calls for revenge, many analysts warned that a military response would be extremely dangerous, and that diplomatic and trade restrictions were far more likely.

Early Sunday, fighters slipped into an army base in Indian-controlled Kashmir, killing at least 15 soldiers. Four militants were killed in the attack, which occurred near the highly militarized Line of Control that divides Kashmir between India and Pakistan. Indian investigators say maps, weapons and other evidence indicated the fighters were from Jaish-e-Mohammed, an outlawed militant group based in Pakistan.

India’s many all-news TV channels have been filled with outrage since the attack, with commentators demanding that India respond forcefully against Pakistan. The calls for punitive action have spread across social media and into Prime Minister Narendra Modi’s own ruling Bharatiya Janata Party, and among his Hindu nationalist supporters.

Ram Madhav, the party’s general secretary, said India needed to hit back hard. “For one tooth, the whole jaw,” he wrote on Twitter.

Modi has tried to assuage the anger, tweeting that, “I assure the nation that those behind this despicable attack will not go unpunished.”

The attack came amid the largest protests against Indian rule in Kashmir in years, sparked by the July 8 killing by Indian soldiers of a popular rebel commander.

The protests, and a sweeping military crackdown, have all but paralyzed life in Kashmir. More than 80 people, nearly all of them protesters, have been killed in the violence.

India has for decades accused Pakistan of funding, training and equipping Islamic militants and then helping them cross into the Indian-controlled portion of Kashmir. Pakistan says it only gives the militants diplomatic and moral support.

Pakistan denied any role in Sunday’s attack, with the Foreign Ministry saying in a statement that it “has noted with serious concern the recent spate of vitriolic and unsubstantiated statements emanating from Indian civil and military leadership.”

India and Pakistan have fought three wars since independence from Britain in 1947, two over Kashmir. Both nations claim the Himalayan province in its entirety. The two countries have held numerous rounds of talks over the years, but never have reached agreement on Kashmir.

In the past, when it was in the opposition, Modi’s party loudly criticized responses to terror attacks by the then-ruling Congress party, calling its leaders weak-kneed and timid.

During the bitter 2014 election campaign that brought him to office, Modi often taunted the Congress by saying that if he became prime minister Pakistan would not dare to provoke India.

A similar attack on an Indian military installation occurred in January, when six gunmen entered an air force base in the town of Pathankot close to the Pakistan border. The rebels paralyzed the massive base for nearly four days, and killed seven soldiers.

India responded by suspending talks with Pakistan, a reaction that also angered many in Modi’s party.

“The government has been trapped by its own rhetoric,” said K.C. Singh, a former diplomat and expert on India-Pakistan relations.

But analysts cautioned Monday that electoral bombast is not supposed to define state policy. If India retaliated militarily, especially with the annual United Nations General Assembly about to begin, global condemnation would be immediate, they said.

“The pressure on the Modi government to act decisively now is visible, but this should be tempered by objective cost-benefit operational analysis,” C. Uday Bhaskar, a defense analyst, wrote in the Indian Express.

No matter how strongly many in India demand a forceful retaliation, analysts say New Delhi’s options are probably limited to imposing diplomatic and trade restrictions on Islamabad.

Some experts have suggested that New Delhi recall its envoy from Islamabad and expel the Pakistani high commissioner. Others say India should close its skies to Pakistani flights or hold military exercises near the Pakistan border.

But whatever measures India decides on, New Delhi will have to consider their implications.

“India has to ensure that the options it exercises — particularly the military ones — do not leave it worse off than before in terms of casualties and costs,” said Manoj Joshi with the Observer Research Foundation, a New Delhi-based think tank.