Asked what he thought of Western civilization, Mohandas Gandhi is said to have answered that it would be a good idea.

Debate about liberal democracy in the Trump era is suffused with similar pessimism about Western achievement, bordering on self-damaging despair. The "liberal" mix of capitalism and democracy is denounced for yielding social inequality, cronyist kleptocracy and sheer governmental incompetence — failings that opened the door to Donald Trump's dispiriting presidency and that may be entrenched by it in turn.

Some go so far as to claim that the chief threat to Americans is not from the aggressively illiberal despots of Russia, North Korea, China or the Islamic theocracies. Rather, it is from the perverse fruit of our own system. The enemy is us.

This intellectual bandwagon needs to be stopped. Liberalism faces two challenges — on the one hand, external enemies; on the other, an internal crisis of self-confidence. And it is time we all acknowledged that the external threat is more severe.

However bad Trump may be, he is not Vladimir Putin or Kim Jong Un. And although it is true that liberalism faces an internal crisis — I've done my bit to contribute to the alarmism — it is worth remembering how liberalism got started two centuries ago.

As Edmund Fawcett has argued in his magisterial history of liberalism, the creed originated as a set of principles for managing bewildering change. For most of human history, economic growth and social evolution proceeded at a snail's pace, but between 1776 and the first decades of the 19th century, revolutions both political and industrial caused everything to speed up. Liberalism — skeptical of central power, respectful of diverse beliefs, comfortable with vigorous disagreement — offered a means of handling the resulting tumult. If headlong technological and economic dislocation made political conflict unavoidable, humanity needed a way to contain it, civilize it — a way to hang on to timeless standards of humanity while providing an escape valve for argument and change.

Seen in this light, today's technological and economic convulsions — the part-time jobs of the "gig" economy, the menacing shadow of the robots — are not signs that the liberal system is in crisis but signs that liberalism is more essential than ever. We are in the midst of another industrial revolution, which will create winners and losers and bitter political arguments — and Trump is testament to that. Liberalism will not end these conflicts; only absolutist doctrines create political silence. But liberalism will set the rules of the game that allow the conflict to be managed.

For now, Trump is expressing the frustration of a part of the country, but liberal checks and rules of process are containing the impact.

In its long history of facilitating clamorous argument, liberalism has succumbed, unsurprisingly, to repeated neuroses. In 1956, Nikita Khrushchev boasted of the superiority of state-directed industrialization, telling a group of Westerners, "we will bury you." Some in the West made the mistake of believing him, especially when the Soviet Union launched the first space satellite the following year.

In the 1960s, U.S. democracy was rocked by political assassinations and a bubbling up of radical challenges to the system. Amid the stagflation of the 1970s, a business-school dean sounded a warning about "an end-to-Western-capitalism syndrome" and no less a figure than the U.S. president lectured the nation on its moral turpitude. All of these episodes generated existential crises. But today's pessimists should note that liberalism emerged robustly from those moments of self-doubt.

What's more, pessimists should remember that, if a few dice had settled differently, the current conversation would be completely different. Trump's election must be accepted as legitimate, but a small swing in a few places would have put the status quo candidate in the White House. Similarly, Britain's Brexit referendum was decided 52 to 48 percent; a recent poll suggested that the voters now have doubts. In France, to cite a contrary example, the ambitious liberal Emmanuel Macron was lucky to face a bevy of weak opponents, and France was even luckier that Macron emerged out of nowhere, clad in white.

The point is that political outcomes often hinge on quirks of fortune. None of these events should be interpreted as durable signals that liberalism is either moribund or resurgent.

Finally, it pays to remember that the two recent disasters that discredited the liberal establishment — the 2008 financial crisis and the Iraq war — were not errors that flowed from liberalism itself. There was nothing liberal about taxpayer backstops for private financial risk-taking, nor about the failure to temper the objective of Iraqi regime change with a sober calculation of available resources. These episodes do hold lessons — avoid cronyism and hubris — but they absolutely do not show that liberalism is wanting.

Liberalism arose during the first industrial revolution. We need it to navigate the second industrial revolution as it roils around us now.

Sebastian Mallaby is the Paul A. Volcker senior fellow for international economics at the Council on Foreign Relations. He wrote this article for the Washington Post.