A woman lights candles during a vigil Tuesday for Indian soldiers killed in an attack at an army base in Kashmir. (Mukesh Gupta/Reuters)

Indian Prime Minister Narendra Modi swept to power in 2014 projecting the image of a strong leader who could bring an end to terrorism and tame nuclear rival Pakistan.

Just over two years later, Modi faces his first big foreign policy test: how to respond to the devastating terrorist attack on an Indian army base Sunday that left 18 soldiers dead in the disputed Kashmir region. More than a dozen of the soldiers were burned to death in their tents.

The Indian government has accused Pakistan of supporting the four militants who sneaked onto the base in the border town of Uri in India-administered Kashmir with assault rifles, grenade launchers and supplies — a charge Pakistan vehemently denied. On Tuesday, the two militaries exchanged artillery fire at a border outpost near Uri.

Control over the verdant Kashmir Valley in the foothills of the Himalayas has been the main source of contention between regional powers India and Pakistan for decades, with an armed insurgency by Muslims seeking autonomy from India often flaring there.

The latest tensions could be thrust onto a wider stage this week at the U.N. General Assembly in New York. Kashmir will probably be the centerpiece of a speech by Pakistan’s prime minister, Nawaz Sharif, at the gathering.

Modi’s top aides say that the prime minister has lost patience with Sharif. India’s response, though measured, will be significant, his administration warned.

“The consistent attempt of the Modi government to have a good relationship with Pakistan has always been responded to with the export of terror,” said Ravi Shankar Prasad, the country’s law and justice minister. “Now our patience stands exhausted. Relations will never be the same again.”

At home, Modi — who campaigned on his image as a strong Hindu nationalist leader — is facing pressure from the media, the public and members of his own party to act swiftly in the coming days.

Hawkish supporters have unearthed some of Modi’s old tweets from his opposition days, when he criticized the former government as being too soft on Pakistan. “Are you not weak?” Modi once tweeted. “If indeed you are a strong government, the country needs proof of that.”

And public opinion in India backs military action, too, according to one poll. The Pew Research Center released results of a public opinion survey Monday that found that 62 percent of Indians surveyed said that “overwhelming force” is the best way to defeat terrorism.

“There is a lot of anger, and the political establishment has been quite aggressive on these counts. People expect the government to do something,” said retired Gen. Ved Prakash Malik, who was the Indian army chief during the last major border conflict between India and Pakistan over Kashmir, in the Kargil district.

Secretary of State John F. Kerry met Monday in New York with Pakistan’s Sharif and expressed “strong concern” over recent violence in Kashmir, said a statement from John Kirby, the State Department spokesman.

Kerry also stressed the “need for restraint” in nuclear weapons programs, the statement said. Pakistan and India are both nuclear powers.

The region erupted in violence yet again in July, when the killing of a popular militant commander named Burhan Wani set off protests that have left more than 70 dead and hundreds more injured or blinded by military pellet guns.

During the conflict, India has accused Pakistan of fomenting unrest among Kashmiris in the villages and through social media, and Pakistan has accused the Indian military of using excessive force, a concern echoed by some human rights groups.

A group of former Pakistani security officials, in an unusual joint statement published Monday, said the country’s association with anti-Indian and anti-Afghan militants has “hurt its international image” and undermined its ability to “forcefully advocate for the Kashmir cause.”

Pakistan, the statement declared, must stop allowing militant groups to “abuse our hospitality.” India has long claimed that Pakistan trains and supports Muslim militants who cross into Indian-controlled Kashmir to attack security forces.

Sharif and Modi made a rare public display of solidarity in December, when Modi made a surprise visit to Lahore to see Sharif and attend his granddaughter’s wedding. But any good will generated by that visit evaporated days later when militants attacked a different Indian military installation, killing seven soldiers and stalling relations yet again.

For the second day since Sunday’s sneak attack, Modi remained cloistered Tuesday with his advisers, considering a range of political, diplomatic and military options.

Experts have said those may include shaming Pakistan and its support of terrorist groups on the global stage, continued diplomatic intervention, boosting security at military camps and cutting off trade ties and water agreements.

A greater military response, such as targeted airstrikes on alleged terrorist training camps inside Pakistan, is not off the table but is fraught with risks, officials say, because it could lead to an escalation in tension between the two nuclear-armed neighbors and take the focus off Modi’s chief priority : expanding the nation’s economy.

The Indian air force presented the government with several options for an air response after the terrorist siege in Mumbai in 2008 by Pakistan-based militants, which left more than 160 people dead. But New Delhi decided against using that option, Malik said.

“There was far too much diplomatic pressure at the time,” Malik said, both from within the country’s Foreign Ministry and from international allies in the West, including the United States.

Pam Constable in Islamabad contributed to this report.