You can also get a visa on arrival from China over the Khunjerab pass in the small border town of Sost. The Chinese sometimes don’t like this but if you keep on insisting they will let you over the border to get your visa. There is more information about this on the Thorn Tree.
Embassies in surrounding countries:
There are embassies in Kazakhstan, Uzbekistan, India and Iran, although with the flexible entry dates available from home embassies you would be wise to get your visa in your home country.
See the individual country pages for requirements.