Creation of Pakistan
Pakistan is the country with the vast majority of Ahmadiyya followers, who mostly migrated from India during the Partition in 1947. With reference to the creation of Pakistan:
Zafrullah Khan was involved with the Boundary Commission, played a political role in the Kashmir war of 1948, was the first foreign minister of Pakistan, and was center-stage during the Events of 1953.
Pakistan - 1947 to 1974
Mirza Mahmud did not wish to migrate to Pakistan. In fact, he vowed to die in Qadian but had to flee at the last minute when Sikh jathas were intent on taking the 'holy' city of Qadian, which they control to this day.
Pakistan - 1974 to present
Ahmadiyyat in Pakistan by S.E. Brush
(BRUSH, S. E. (1955), AHMADIYYAT IN PAKISTAN. The Muslim World, 45: 145–171 – Volume 45, Issue 2, pages 145–171, April 1955)
Charles Kennedy's Paper
Professor Charles H. Kennedy has written a paper (PDF, 17 MB) on the policy of the Government of Pakistan and the laws that affect the Ahmadiyya.
1974 Constitutional Amendment
Supporting Zulfiqar Ali Bhutto in his successful election as Prime Minister of Pakistan, the Ahmadiyya leadership once again exhibited the irrationality of being close to power as they did in the 1930s and privately protested the 1973 2nd Islamic Summit in Lahore. In April 1974, Bhutto also sacked [Zafar Ahmad Chaudhry] the Air Chief of Staff of the Pakistan Air Force and the Air Force held a court-martial against senior Air Force officers, some of whom were Qadiani Ahmadi. This resulted in the Ahmadiyya leadership being angry at Bhutto, who is reported to have replied 'I am not the Prime Minister of only the Ahmadis, I am the Prime Minister of Pakistan.'
This political frustration led to the Ahmadiyya [attack on the train] passing through their headquarters, Rabwah, triggered riots and eventually led to the 2nd Amendment to the nascent Constitution of Pakistan:
. . . (3) A person who does not believe in the absolute and unqualified finality of the Prophethood of Muhammad (peace be upon Him), the last of the Prophets or claims to be a prophet, in any sense of the word or of any description whatsoever, after Muhammad (peace be upon Him), or recognises such a claimant as a prophet or a religious reformer, is not a Muslim for the purposes of the Constitution or Law.
Since the Pakistan Constitution requires the President and Prime Minister to be Muslim, and because of their opposition to the 2nd Islamic Summit, and taking the law into their hands in an organized fashion, anti-Ahmadiyya forces had political strength. Politicians and military officials were also wary of the blind obedience that senior civil servants and military commanders had to pledge as a condition of being Ahmadi. At the time, the most senior civil servant in Pakistan in Pakistan was [Mirza Muzaffar Ahmad], and some very high-ranking military officers were also Ahmadi.
Since that time, Ahmadis are, by convention, barred from holding any rank above Colonel in the armed forces, and high civil service posts. Anti-Ahmadiyya groups monitor this with vigilance.
Allama Muhammad Iqbal, in 1935, had asked the British to declare the Qadianis as separate community just as they had done with regard to the Sikhs (in 1919 the Sikhs were declared separate from the Hindus although the High Court had ruled that the Sikhs were a part of the Hindu religion). As Iqbal said, 'the Qadianis while pursuing a policy of separation in religion and social matters' were, however, anxious to remain politically within the fold. (Impact Magazine, http://www.alhafeez.org/rashid/constipak.html)
Changes to Pakistan Penal Code
As the Qadiani Ahmadiyya did not accept the Second Amendment, their activities started to take on a nature of resistance and complaints of 'persecution'. Since Ahmadis were readily granted asylum in Western countries, many Muslims would convert to the Ahmadiyya (and still do) in order to apply for asylum. In addition, Ahmadiyya publications did not comply with the spirit of the law and repeated warnings from the government to keep their terminology non-provocative to general Muslims.
Also, see the discussion on the Law on Freedom of Religion.
Pakistan Penal Code (Second Amendment) Ordinance, XLIV of 1980
This was a shot across the bow and was couched in neutral terms that did not mention the Ahmadiyya:
*298-A. Use of derogatory remarks, etc., in respect of holy personages:*
Whoever by words, either spoken or written, or by visible representation, or by any imputation, innuendo or insinuation, directly or indirectly, defiles the sacred name of any wife (Ummul Mumineen), or members of the family (Ahle-bait), of the Holy Prophet (peace be upon him), or any of the righteous Caliphs (Khulafa-e-Rashideen) or companions (Sahaaba) of the Holy Prophet (peace be upon him) shall be punished with imprisonment of either description for a term which may extend to three years, or with fine, or with both.
The Ahmadiyya continued to use the word 'ummul-mumineen' for the wives of their founder whereas it is universally used for the wives of the Prophet Muhammad(saw) and other such terms described above, respectively.
Anti-lslamic Activities of Quadiani Group, Lahori Group and Ahmadis (Prohibition and Punishment) Ordinance, XX of 1984
The 'persecution' of Ahmadis had been advantageous for the group in terms of the financial well-being of its members, and resultant contributions. The Ahmadiyya did not make any attempt to reconcile its differences with the law. The government again amended the Penal Code to include the following:
298-B. Misuse of epithets, descriptions and titles, etc., reserved for certain holy personages or places:
(1) Any person of the Quadiani group or the Lahori group (who call themselves 'Ahmadis' or by any other name who by words, either spoken or written, or by visible representation-
(a) refers to or addresses, any person, other than a Caliph or companion of the Holy Prophet Muhammad (peace be upon him), as "Ameer-ul-Mumineen", "Khalifatul- Mumineen", Khalifa-tul-Muslimeen", "Sahaabi" or "Razi Allah Anho";
(b) refers to, or addresses, any person, other than a wife of the Holy Prophet Muhammad (peace be upon him), as "Ummul-Mumineen";
(c) refers to, or addresses, any person, other than a member of the family "Ahle-bait" of the Holy Prophet Muhammad (peace be upon him), as "Ahle-bait"; or
(d) refers to, or names, or calls, his place of worship a "Masjid";
shall be punished with imprisonment of either description for a term which may extend to three years, and shall also be liable to fine.
(2) Any person of the Qaudiani group or Lahori group (who call themselves "Ahmadis" or by any other name) who by words, either spoken or written, or by visible representation refers to the mode or form of call to prayers followed by his faith as "Azan", or recites Azan as used by the Muslims, shall be punished with imprisonment of either description for a term which may extend to three years, and shall also be liable to fine.
298-C. Person of Quadiani group, etc., calling himself a Muslim or preaching or propagating his faith:
Any person of the Quadiani group or the Lahori group (who call themselves 'Ahmadis' or by any other name), who directly or indirectly, poses himself as a Muslim, or calls, or refers to, his faith as Islam, or preaches or propagates his faith, or invites others to accept his faith, by words, either spoken or written, or by visible representations, or in any manner whatsoever outrages the religious feelings of Muslims shall be punished with imprisonment of either description for a term which may extend to three years and shall also be liable to fine.
Also, see the discussion on the Law on Freedom of Religion.