Leaders from Afghanistan, Pakistan and Turkmenistan have signed a long awaited deal to build a natural gas pipeline through the three countries.

When completed, the natural gas pipeline will stretch 1500 kilometers from Turkmenistan, across Afghanistan and into Pakistan, and cost billions of dollars.

Afghan leader Hamid Karzai, Pakistani Prime Minister Zarafullah Jamali and Turkmen President Saparmurat Niyazov signed the agreement Friday in the Turkmen capital, Ashgabat.

Most of Turkmenistan's natural gas exports now go through Russia, and the Turkmen government has long wanted to open up other avenues for export. But that meant going through Afghanistan which until recently was under the control of the Taliban and other warring factions.

During the 1990s, a U.S. consortium led by the U.S. energy company Unocal, considered investing in the pipeline project. But the idea was abandoned after the United States launched a missile attack against al-Qaeda training bases in Afghanistan. The missile attack was in response to attacks on embassy compounds in Africa that U.S. officials blamed on al-Qaeda.

If it is built, the pipeline will help Turkmenistan open up its natural gas fields and give Pakistan access to more sources of energy.

Afghanistan would also benefit because it would be able to collect transit fees from companies using the pipeline, money it needs to rebuild its country after years of war.

But there are still several obstacles to overcome before the pipeline is completed.

Many parts of Afghanistan are still controlled by regional warlords or bandits, which would make construction difficult. The security situation in Afghanistan is also continuing to make international investors leery of the project.

There has also been talk of extending the pipeline to India but Indian leaders have been wary of taking part in a project that would make them rely on energy passing through their rival, Pakistan.