In 1970–1979, Southern Caucasus republics of the Soviet Union were supplied by natural gas from Iran. After Iranian Revolution Iranian supplies were cut off. To replace Iranian gas supplies from Western Siberia and Orenburg through
Novopskov were planned. For this purpose, the North Caucasus–Moscow line was reversed and expanded further south by construction of the Mozdok–Makhachkala–Kazi Magomed and Mozdok–Tbilisi–Kazi Magomed pipelines. The Mozdok–Makhachkala–Kazi Magomed pipeline was completed in 1983.
In 2007, Azerbaijan started its own gas production and the pipeline between Russia and Azerbaijan became largely inactive. In the summer of 2008, Gasprom started negotiations with State Oil Company of Azerbaijan on buying natural gas from Azerbaijan at market prices based on long term agreement between two countries. It had been announced earlier that Russia was willing to diversify its imports and purchase natural gas from Azerbaijan's Shah Deniz gas field.
On 29 June 2009, during an official visit of the Russian President Dmitry Medvedev to Azerbaijan, governments of both countries signed a deal on exports of Azerbaijani gas to Russia. As per agreement, Russia would be paying Azerbaijan $350 per thousand cubic meters while paying only $300 per thousand cubic meters for Uzbek and Turkmen gas. Under the terms of the deal, Azerbaijan is to sell Russia 0.5 billion cubic meters annually with a possibility of increase of the volume to 1.5 in the future.
On 14 October 2009, President of State Oil Company of Azerbaijan, Rovnag Abdullayev and CEO of Gasprom, Alexei Miller, finalized the deal. The agreement oversees the exports for 2010-2014 with a potential for extension.
Azerbaijani natural gas would be transported via the Baku-Novo Filya pipeline, which was previously used for transporting of natural gas from Russian to Azerbaijan, until 2007, when the shipments were stopped by Azerbaijan as a result of internal self-sufficient production. On January 21, during the meeting between Alexey Miller and Rovnag Abdullayev Gasprom expressed its willingness to purchase more gas from Azerbaijan. The parties agreed to double the amount of gas to be transport during 2010 from initially planned 500 million cm to 1 billion cm and yet increase the amount to 2 billion cm in 2011.
Starting from 2007, Azerbaijan became exporter of natural gas by starting its shipments to Georgia and Turkey.