The right thing, done the wrong way. That may well be history's judgment on President Obama's plan to shield millions of immigrants from deportation.

Obama's executive action answers compelling calls to bring more order, compassion and even natural justice to a broken immigration system. Yet at the same time the president risks breaking the doctor's oath: first, do no harm.

The political system — indeed the social contract that binds America's leaders and an unhappy, anxious electorate — is already in fragile shape.

The president has spotted a real ill in the way that immigration laws function. But his proposed cure is unprecedented in its radicalism and scope. He seems set to grant legal papers to millions of foreigners, notably the parents of children who are citizens or legal residents. The reaction from opponents in Congress and the country may leave deep scars.

If congressional Republicans attempt even a fraction of what the hard right is demanding as revenge — from impeachment hearings to passing bills that defund what they call an unconstitutional "amnesty" — historians may pinpoint last week's TV address as the moment that hopes for substantial bipartisan cooperation faded, just 16 days after midterm elections that saw Republicans take the Senate and increase their majority in the House of Representatives.

Before history-writers set to work, it is worth considering how Obama decided that this was the right thing to do.

The case for action is not hard to make. Successive governments have stood by as America became home to more than 11 million illegal residents. That is a huge number in a country ruled by law, and tantamount to a "de facto amnesty" as both Republican and Democratic advocates for reform have said. Many of those foreigners arrived years ago, working hard and bringing up American children. But their families have enjoyed only provisional futures, overshadowed by the original sin of a parent or parents who arrived without the right papers. A traffic stop by police or a raid on a workplace has been enough to drag car mechanics, plumbers and waitresses into a deportation system meant to target convicted felons, recent border-crossers and threats to public safety.

Since Obama took office, more than 2 million foreigners have been removed. Every country has the right to police its borders, but those removals divided a lot of otherwise law-abiding families, punishing youngsters who had done no wrong.

Congress could and should have passed a comprehensive law that made Obama's unilateral actions unnecessary. In June 2013 a bipartisan majority of senators passed an immigration reform that — though unwieldy — would have brought millions of migrants in from the shadows and eased rules for some legal workers while boosting the (already vast) funds spent on border security. Alas, the plan was deemed too close to an "amnesty" in the House, a body crammed with members in super-safe districts whose main fear is not general elections but internal party rivals trying to grab their seats.

Even before the president unveiled his plans, Republicans set out their objections. Many reek of opportunism, some of hypocrisy: plenty of Republicans accusing Obama of poisoning the well of bipartisanship have spent six years trying to thwart his every move. But it is possible for predictions of future doom to be both hypocritical and correct.

The strongest Republican charges concern precedent. Yes, as White House aides never tire of pointing out, other presidents back to Eisenhower have deferred deportation for specific groups facing wars or persecution. In 1990 George Bush senior also decreed that the spouses and children of people legalized under a 1986 immigration act should not be deported. But Obama's actions are set to dwarf anything tried before, and unlike Bush's 1990 move, are not a tweak to fix an ill-drafted law.

Many Republicans are sincerely aghast at the implications of letting Obama offer legal status — even temporarily — to millions with a pen-stroke (indeed, the president once seemed to agree, telling immigration activists who shouted that he had the power to stop deportation, "Actually, I don't"). As one unhappy Republican senator put it privately this week, could a future president from his party scrap corporation tax? That too would be wrong.

Other Republican arguments are more self-serving. Centrist Republicans who favor immigration reform (not least because yelling about "amnesty" repels Hispanic voters) fret that Obama is going to awaken their party's angry nativists — but it is hardly the president's job to save Republicans from themselves.

A spokesman for John Boehner, the Republican Speaker of the House, said Nov. 19 that if "Emperor Obama" ignores his previous qualms about the limits of presidential power, he will "ruin the chances" for congressional action on immigration — though there is no evidence that Boehner was about to ask his fractious members to help Obama pass ambitious reforms.

Obama's biggest problem, however, is not Republicans. It is his apparent certainty that he hears a mandate to act in the national interest, because the country is tired of gridlock. A day after the Republicans' recent victory he harked back to his presidential wins, calling himself "the guy who's elected by everybody, not just from a particular state or a particular district." He said he heard a message from voters but also from " the two-thirds of voters who chose not to participate in the process yesterday."

That is perilously close to politics by telepathy: a lethal delusion that can afflict embattled leaders. Obama is right that presidents enjoy a unique role in American democracy. It is true that voters are sick of gridlock.

But many are also tired of him.

Copyright 2013 The Economist Newspaper Limited, London. All Rights Reserved. Reprinted with permission.