Saudi ⁠Arabia, Pakistan and Turkiye have signed a ⁠joint defence agreement, Pakistan’s ⁠foreign ministry said, deepening ‌security cooperation amid heightened military tensions and conflicts in the Middle East.

Pakistan’s ⁠foreign ministry on Friday said the agreement states ⁠that an armed ⁠attack on any one of the ⁠three countries would be ⁠regarded as an ⁠attack against them all.

It reflects “the three states’ shared commitment to further strengthening their collective security and to promoting peace, security, and stability in the region and beyond, in pursuit of a secure and prosperous future,” the statement added.

The deal comes a day after Pakistani Prime Minister Shehbaz Sharif, accompanied by powerful army chief Asim Munir, arrived in Saudi Arabia and performed the Umrah pilgrimage in Mecca.

Turkish President Recep Tayyip Erdogan also travelled to Saudi Arabia on Friday to meet Saudi Crown Prince Mohammed bin Salman, whose country has been struck repeatedly by Iran, as well as by Tehran’s Houthi allies in Yemen and Shia armed groups in Iraq, since the US and Israel attacked Iran on February 28.

The conflict has imperilled Saudi Arabia’s oil exports and ⁠ambitious development plans, and raises big questions on the reliability of its longstanding US security umbrella.

While Turkey and Pakistan have avoided significant direct attacks, both are anxious to calm regional conflicts that threaten their security and economy.

The deal among the three countries follows nearly a year of negotiations. Sealing the agreement in Mecca, the holiest site in Islam, adds symbolic heft to a pact that builds on longstanding bilateral military ties.

Pakistan has provided training and technical assistance to Saudi forces for decades, while Turkiye and Pakistan have exchanged warships ⁠and training aircraft. In 2023, Riyadh agreed to buy Turkish drones in what Ankara called its largest defence export contract.

Al Jazeera’s Osama Bin Javaid, reporting from the Qatari capital Doha, said the pact “essentially puts three of the largest Muslim populations together”, marking the beginning of a “different security architecture” in the region.

“Pakistan brings with it, obviously, its nuclear arsenal, battle-hardened military, and munitions it has been supplying,” Javaid said. “Turkiye, with its advanced drone and munitions systems, is a NATO member, combined with the economic power of Saudi Arabia.”

Reporting from the Turkish capital, Al Jazeera’s Resul Serdar said that while the deal was purely defensive, such agreements bring about cooperation in other sectors, too. “It’s all about the trust now,” Serdar said. “There are expectations in Ankara that this will also boost economic ties with Riyadh and Islamabad.”