JERUSALEM – The rapidly shifting colors of the geopolitical map of the Middle East projected a surprising new hue over the weekend when nuclear-armed Pakistan warned its nuclear-ambitious neighbor Iran against tangling with Saudi Arabia.

After meetings between the Saudi defense minister Mohammed bin Salman and Pakistan’s military leadership, the Pakistani army issued a statement Sunday asserting "that any threat to Saudi Arabia’s territorial integrity would evoke a strong response from Pakistan".

The spiraling regional tension follows the execution by Saudi Arabia this month of dissident Saudi Shiite cleric, Sheikh Nimr al-Nimr, who was revered in Iran. A mob in Tehran retaliated by sacking the Saudi embassy. Saudi Arabia promptly severed diplomatic relations with Iran, as did other Sunni-dominant states in the Gulf region and elsewhere.

Pakistan normally enjoys good relations with Iran, with which it has commercial ties. As the Pakistani newspaper, Dawn, put it, "Iran is an important neighbor, possibly on the verge of an economic breakout" as Western sanctions are lifted. However, Islamabad has come under a diplomatic blitz from Saudi Arabia, which has been a generous benefactor in the past, to stand shoulder-to-shoulder with its fellow Sunni nations.

Last week, Adel al-Jubeir, the Saudi foreign minister, flew to Pakistan to meet with its leaders and was immediately followed by bin Salman. Prime Minister Nawaz Sharif of Pakistan sought to avoid too tight an embrace after his meeting with the foreign minister, saying that Pakistan was willing to mediate between Saudi Arabia and Iran, but the statement by the generals after their meeting with the defense minister threatening a "firm response" was that of an ally, not a middle man. Sharif toughened his stance after his meeting with the 31-year-old defense minister, bin Salman, deputy crown prince of Saudi Arabia and favorite son of the aging King Salman. "The people of Pakistan will always stand with the people of Saudi Arabia," he said. "Pakistan holds its defense ties with Saudi Arabia in highest esteem."

Apart from its nuclear capability, Pakistan has a standing army of more than 500,000 troops as well as 500,000 reservists. More than any other Muslim nation it has the capacity to stand up to the Iranian armed forces. Although not actually part of the Middle East—it is considered part of South Asia or the Indian subcontinent—it has played a role in the region as a close neighbor and religious affiliate. It has stationed thousands of soldiers in Saudi Arabia in the past whenRiyadh felt threatened by Iraq’s Saddam Hussein. It has been Saudi Arabia that was the principal benefactor in this relationship. It has provided generous financial aid to Pakistan over the years and also employs 1.5 million Pakistanis whose remittances home are vital to the Pakistani economy.

Although it is a Sunni-majority country, Pakistan also has a sizeable Shiite minority. Violent clashes between the two sects in Pakistan have taken the lives of thousands in recent years, mostly Shiites.

Iran has for years been the most assertive nation in the Middle East as it attempts to attain regional hegemony. Its military presence is felt through proxies in Lebanon, Syria, Iraq, Yemen and Gaza. However, its sense of manifest destiny has suddenly encountered bumps in the road it had not anticipated. Both its military and political leadership have expressed regrets at the sacking of the embassy.

Saudia Arabia’s new assertiveness has been prompted by a sense that its long-time ally and supporter, the United States, has shifted its strategic stance in the region and is seeking conciliation with Iran, as evidenced by the recent nuclear agreement with Teheran.

Riyadh is therefore pressing its potential Sunni allies to rally to its side. Some of them would prefer not being pressed. As a senior Pakistani official put it to a Western journalist, his country was part of the Saudi-led Sunni coalition "but we will only act in our national interest."