Pakistan is one of the most repressive countries in the world with regard to freedom of expression, including and especially religious freedom. Blasphemy (i.e. insults) against religion in general can result in imprisonment, while blasphemy against Islam carries the much harsher punishment of death. Both in terms of the aggressiveness with which the Islamic-conservative government prosecutes such cases, as well as the harshness of punishment, Pakistan remains one of the worst places on the planet to speak out against religion or religious fundamentalism.
The lands that today encompass Pakistan began to undergo the process of Islamization in the early eighth century, but the process of the religious conversion of most of its populace took several centuries. In the succeeding centuries, the region passed through the hands of multiple Islamic empires and sultanates, including the Mughal Empire, before ultimately being colonized by the British as part of British India.
Pakistan's current penal code has its ultimate source in the penal code of British India, out of which the modern independent states of India, Pakistan, and Bangladesh splintered. This penal code had a general blasphemy provision against insulting religious beliefs, intended as a means of facilitating greater religious harmony among the diverse population of the British colony. This law remains on the books today, as it does in the other nations as well.
However, Pakistan is unique in that, after independence (which came in 1947), in keeping with the explicitly religious character of the new "Islamic Republic," the penal code was amended with provisions to punish blasphemy against Islam specifically. These provisions prohibit insults to both the Islamic faith and to the Qur'an, and, unlike the general blasphemy law which carries the punishment of imprisonment, these carry the death penalty. The current constitution, adopted in 1973, gives Islam as the state religion and stipulates that legislation may not contravene the principles of Islamic law.