Pakistan and Iran have historically close relations due to their shared border, religious and cultural ties. Iran was the first country to recognize Pakistan after its independence. The two countries have supported each other in times of need, such as during the 1971 war for Bangladeshi independence and after natural disasters. While relations became strained after Pakistan allied with the US post-9/11, the two countries have sought to improve economic and security cooperation in recent years through projects like gas pipelines and improving border management. High-level military visits between the two countries in 2017 and 2018 aim to further strengthen bilateral relations.