Pakistan has experienced three periods of martial law since gaining independence in 1947. The first was declared in 1958 by President Iskander Mirza and Chief Martial Law Administrator General Ayub Khan due to political instability. Ayub Khan lifted martial law in 1962 after nearly four years. The second was declared in 1969 by General Yahya Khan after President Ayub Khan resigned. The third was imposed in 1977 when General Zia ul-Haq overthrew Prime Minister Zulfikar Ali Bhutto. While not officially martial law, General Pervez Musharraf also seized power in a bloodless coup in 1999, dissolving the elected government.