Pakistan's captain Sarfraz Ahmed, right, celebrates the dismissal of India's Ravichandran Ashwin, left, during the ICC Champions Trophy final at the Oval in London on June 18. (Kirsty Wigglesworth/AP)

ISLAMABAD, Pakistan — Army troops whooped and cheered in remote barracks. Pandemonium erupted around TV sets in crowded city markets. Banks and oil companies took out full-page newspaper messages. The prime minister sent a video congratulating the nation from a pilgrimage in Saudi Arabia.

In a word, Pakistanis went ballistic Sunday evening when their national cricket team unexpectedly trounced India, the country’s next-door nuclear archrival, in an international championship finals match played in London. India was heavily favored, but Pakistan dominated the match and won by 180 runs.

The stunning upset in the ICC Champions Trophy competition, which came during an extended period of tension between India and Pakistan over the divided border region of Kashmir, triggered an outpouring of patriotic joy tinged with vengeful triumphalism, as well as new hopes for a rehabilitation of Pakistan’s pariah status in the world of international sports.

No major foreign sports team has played in Pakistan since 2009, when a squad of heavily armed gunmen ambushed a bus carrying players from Sri Lanka’s national cricket team to a match in Lahore.

The attack, attributed to an extremist Sunni Muslim militia based in Pakistan, killed six Pakistani police officers and two civilians and wounded six of the visiting team members.

“Everyone will remember this achievement, not just for today or tomorrow but for a long, long time. I hope all nations will now come and play cricket in Pakistan,” the team’s captain, Sarfraz Ahmed, 30, told a news conference after the daytime game at London’s Oval stadium.

It seemed unlikely that Pakistan’s performance would do much to improve the country’s reputation as a dangerous venue for foreign teams, given the continued predations of extremist militant groups. Just six months ago, a spate of terrorist bombings in Lahore and other cities left hundreds of civilians dead.

But for millions of Pakistani Muslims, suffering through sweltering heat in the fasting month of Ramadan, the victory unleashed a burst of cathartic relief and euphoria. It was already dark here when the match ended, and caravans of fans circled city streets, honking and waving flags. Celebratory gunfire could be heard in the capital.

“Today I feel I am a boy again,” said Javed Nasir, 41, a cloth seller in a working-class neighborhood, who said he had played cricket in school and still vividly remembered when Pakistan won the world championship in 1992. “It was my longtime dream that we would defeat India in a match,” he said. “Now our long drought of defeats has ended, and what a gift that is for us during Eid and Ramadan.”

When Ramadan ends later this week, Muslims across the world will celebrate the festival of Eid al-Fitr, feasting and exchanging gifts.

“This was a historic moment for the youth of this country, because we won against our enemy India,” said Rafiq Haider, 20, a college student who was shopping for Eid. “The Indians were so arrogant and boasting about their long batting order, but Amir crushed them. I want to tell India never to think of fighting us. You will lose in every field.” Mohammad Amir is Pakistan's star bowler, or pitcher.

Pakistan was once a part of Hindu-majority India, but it was broken off and created as a new Muslim homeland in 1947 amid violent tumult. Since then, the two countries have fought three limited wars, and both have successfully tested nuclear weapons, drawing international sanctions.

Some comments Sunday were darker and politically pointed, including tweets by military officials that alluded to the ongoing violence in the Indian portion of Kashmir, where security forces constantly battle rock-throwing demonstrators, and to Pakistani accusations and suspicions of spying by India in the troubled desert province of Baluchistan.

The army’s public relations office circulated a video of Muslims in Srinagar, the embattled major city in Indian Kashmir, celebrating the cricket victory, and also tweeted an indirect warning about Baluchistan that said, “To whom it may concern: Lay off!!”

In Sunday’s match, Pakistan batted first and scored 338 runs during 50 overs, or turns at-bat, before all its batsmen were called out because of missed or caught balls. India, which had easily defeated Pakistan in the opening match, was able to score only 158 runs before all its batsmen were called out after 30 overs.

Many sportswriters and commentators could not resist using belligerent and military metaphors to describe the contest. One headline even described Pakistan as “decapitating” India’s batting lineup, evoking a gruesome, highly sensitive issue in which India has accused Pakistan of mutilating and beheading the corpses of Indian border troops.

Prime Minister Nawaz Sharif, a champion of bilateral rapprochement, was more diplomatic. He congratulated the team for its “remarkable performance” and “classic victory,” called on the “entire nation to rejoice” and said he looked forward to welcoming the team back home. Of India, he made no mention at all.

Shaiq Hussain contributed to this report.