In 2007, Nawaz Sharif attempted to return from exile but was blocked. Benazir Bhutto returned from an eight-year exile, preparing for the 2008 elections but was targeted in a deadly suicide attack. Musharraf's proclamation of a state of emergency in November 2007, which included sacking Supreme Court judges and banning private media, led to widespread protests.
Sharif returned to Pakistan in November 2007, with his supporters detained. Both Sharif and Bhutto filed nominations for the upcoming elections. Bhutto was assassinated in December 2007, leading to controversy and investigations into the exact cause of her death. The elections, initially scheduled for January 8, 2008, were postponed due to Bhutto's assassination.
The 2008 general elections in Pakistan marked a significant political shift, with the left-leaning Pakistan Peoples Party (PPP) and the conservative Pakistan Muslim League (PML) gaining a majority of seats. This election effectively ended the dominance of the liberal alliance that had been prominent during Musharraf's rule. Yousaf Raza Gillani, representing the PPP, became the Prime Minister and worked to overcome policy deadlocks and lead a movement to impeach President Pervez Musharraf. The coalition government, spearheaded by Gillani, accused Musharraf of undermining Pakistan's unity, violating the constitution, and contributing to an economic impasse. These efforts culminated in Musharraf's resignation on August 18, 2008, in a televised address to the nation, thereby ending his nine-year rule.