How Pakistan's prime minister survived a crisis