It's fitting that the death of the great Czech playwright/philosopher of democracy, Vaclav Havel, overlapped the demise of North Korea's despotic Kim Jong Il.

And it's equally fitting that his death came as Egypt's military rulers are attacking opposition activists in the aftermath of the Arab Spring.

We all remember Havel as the leading East European dissident of the 1980s who became the first president of Czechoslovakia after communism's fall in 1989. But fewer recall how long and at what cost Havel struggled for his beliefs, during decades when no one thought the Soviet empire would crumble.

Fewer still will recall his later insights into the difficulty of transferring Western-style democracy to other cultures, and what he thought we should do to help.

There can be no greater contrast than that between the Czech champion of individual freedoms and the North Korean tyrant whose rule doomed millions. Yet Havel understood that no despotism is permanent and that brave individuals can surmount overwhelming odds.

I first met Havel when I lived in Prague in 1968 during the Prague Spring. Havel insisted, contrary to many of his fellow intellectuals, that the totalitarian communist system couldn't be reformed, but must be overturned.

After the 1968 invasion, he was shadowed, harassed, forbidden to publish, and repeatedly jailed. When I visited him in 1973 at his country home in northern Bohemia, the secret police had built a shack opposite the front gate to watch all his movements.

Yet he wrote - and smuggled abroad for publication - such seminal essays as The Power of the Powerless. That essay argued that even an ordinary person could help crack the facade of totalitarianism by publicly rejecting the constant lies upon which such systems are based.

Of course, the price for "living in truth" was high, not just in jail time, but in punishment of dissidents' families. In North Korea, the price is clearly too high for real opposition to form - for now.

Yet, even though only a few thousand Czechoslovaks supported Havel's Charter 77 movement, they inspired opposition elsewhere in Eastern Europe. Although many in the West thought communism was immutable, Havel argued that brittle totalitarian regimes would crumble once they began cracking. The cracks would emerge, he said, once people stopped believing the lies they'd been fed.

Havel received a euphoric welcome in Congress when he addressed a joint session in February 1990, and seemed to symbolize the potential triumph of democracy worldwide. Yet even in that speech, he warned that "democracy in the full sense of the word will always remain an ideal" and should be approached as "one would a horizon" - even in America. (Wonder what he'd make of our democracy now.)

In 1994, when he came to Philadelphia to receive the Liberty Medal (and I got to take him around the bars of South Street), his warnings were more pointed. In an increasingly globalized world, he said, people tend to "cling to the ancient certainties of their tribe." This could undermine democratic trends.

When I last saw him, in 2010 in Philadelphia, where the Wilma Theater put on the U.S. premier of his play Leaving, he was even more worried about the dizzying effects of globalization and the tendencies of autocratic governments to react by tightening political control.

Yet, he told me, he advised Chinese democracy-seekers who came to consult him that they should not give up. "You must never expect instant success," he told them. "You never know how things will turn out." That sentence probably sums up North Korea's future as well.

When it comes to Western efforts to export democracy to countries where it isn't well understood, Havel was even more cautious. He said Westerners often confuse democracy with institutions such as legislatures rather than values.

"I think we shouldn't be speaking about democracy so much as human rights and human freedom. Any given country should then translate these ideas into institutions that fit their traditions. I'd be very careful with the export of democracy.

"I put special stress on the idea of human dignity," he added, "something I became acutely aware of when I was in prison." Human dignity is probably what the angry young working-class Egyptians in Tahrir Square have been seeking in the last few days.

That yearning for dignity may lead to very different political outcomes in Mideast countries, even new despotisms based on religion. But Havel believed the struggle for human dignity couldn't be suppressed forever, even if it could be set back for decades.

"You should do things because you consider them to be right," Havel told me. That is the message of his extraordinary life.

E-mail Trudy Rubin at trubin@phillynews.com.