Iran and Pakistan established relations on 14 August 1947, the day of the independence of Pakistan, when Iran became the first country to recognize Pakistan. Both countries remain close allies and formed alliances in a number of areas of mutual interest, such as combating the drug trade along their border the insurgency in Balochistan.
During the Cold War (1945–1991), both countries were part of the Western Bloc against the Eastern Bloc. They were founding members of the anti-communist alliance CENTO. Iran aided Pakistan in the Indo-Pakistani War of 1965 and Indo-Pakistani War of 1971. Both countries shared a common animosity towards Baloch separatists and cooperated in the 1970s Balochistan operation. Iran backed Pakistan in the Bangladesh Liberation War and Indo-Pakistani War of 1971. Following the Iranian Revolution (1978–1979), which overthrew the Pahlavi dynasty, Pakistan was one of the first countries to recognize the Islamic Republic of Iran. During the Soviet–Afghan War (1979–1989), Iran backed the Pakistan-funded Afghan mujahideen and Pakistan supported Iran in the Iran–Iraq War (1980–1988). Following the September 11 attacks, Iran and Pakistan joined the war on terror. Pakistan has often served as a mediator in the Iran–Saudi Arabia proxy conflict. Pakistan has also provided support to Iran in the Iran–Israel proxy conflict
Pakistan is one of the few countries where Iranian influence is positively received as per polls conducted by the Pew Research Center. Polls have consistently shown that a very high proportion of Pakistanis view their western neighbour positively. Supreme Leader of Iran Ayatollah Khamenei has also called for the sympathy, assistance, and inter-cooperation of all Muslim nations, including Pakistan. Iran has also expressed an interest in joining the China–Pakistan Economic Corridor as part of the larger Belt and Road Initiative. After the U.S. complete withdrawal of its troops and the Taliban return to power in the 2020s, Pakistan has stepped up cooperation with Iran to promote peace and stability in Afghanistan.