After nine difficult years, Pakistan's President Pervez Musharraf has resigned. A man once celebrated as the savior of his country has been forced from office, his reputation in tatters, his nation no better off than it was when he seized power. Mr. Musharraf's fate is a reminder of the folly of permitting autocrats to destroy democracy and the dangers of building relations with leaders, rather than the governments they represent.

Mr. Musharraf was Pakistan's Army chief of staff when he seized power in 1999, overthrowing then Prime Minister Nawaz Sharif after the two men argued over the disastrous Kargil offensive. Many of Pakistan's friends were pleased to see Mr. Sharif and his government go, riddled as it was with corruption and incompetence. Mr. Musharraf's pledge to keep military rule short and pave the way for true democracy further encouraged those governments to swallow their complaints.

Instead, two years later Mr. Musharraf declared himself president and rammed through legislation that legitimized his rule and extended his term. The election that followed in 2002 was roundly dismissed as rigged, but it gave Mr. Musharraf's new party a majority of seats in Parliament and provided a democratic veneer for his continued rule. He tried to engineer a similar outcome when faced with the next round of parliamentary elections five years later, but his efforts — particularly when he tried to force the chief justice of the Supreme Court, Mr. Iftikhar Chaudhry, to resign — drew up the judiciary and the opposition against him. He imposed emergency rule before the election to purge the judiciary, but damage was done.