Before Tuesday night, Barack Obama was slated to become the most important American president since Ronald Reagan, a liberal icon in the mold of LBJ or FDR who deeply reshaped the federal government.

Just think about everything that changed during his presidency. He signed into law a comprehensive national health insurance bill, a goal that had eluded progressive presidents for a century. He got surprisingly tough reforms to Wall Street passed as well, not to mention a stimulus package that both blunted the recession and transformed education and energy policy.

He's put in place the toughest climate rules in American history and signed a major international climate accord. He opened the US to Cuba for the first time in more than half a century, and reached a peaceful settlement to the nuclear standoff with Iran. He opened the military to LGBTQ Americans and appointed Supreme Court justices who made same-sex marriage the law of the land.

And now, with the election of Donald Trump and Republican majorities in both houses of Congress, almost all of that legacy is imperiled. Trump has promised to repeal Obamacare, to dismantle the Dodd-Frank financial reforms, to reverse the deal with Iran, and to scrap all climate regulations. Much of that he could do with executive power alone. The rest could be done with a cooperative Congress, in some cases even without a filibuster-proof majority.

We don’t know yet how much Trump, Paul Ryan, and Mitch McConnell will actually be able to do. But if they do what they’ve promised, Obama’s ultimate legacy will be greatly diminished. Maybe his policies would be brought back by future presidents — but maybe they’ll be gone forever. Maybe, like Ulysses S. Grant, he will go down as a president who enacted a huge number of crucial, socially progressive policies that were abandoned as soon as he left office.

What Donald Trump can do to Obamacare, the president’s greatest achievement

The Patient Protection and Affordable Care Act and the Health Care and Education Reconciliation Act of 2010 touched almost every aspect of American health care policy. They created massive new subsidies for insurance for people not poor enough to be covered by Medicaid. They greatly expanded Medicaid too. They also set new protections for women, people with preexisting conditions, and people 26 and younger to expand their access to health care.

But the most important thing those laws did, the thing that cemented Obama’s legacy as an expander of the American welfare state in the tradition of LBJ or FDR, was establish that it was the responsibility of the US government to provide its citizens with health care.

As Brian Steensland, a sociologist who studies American social policy at Indiana University–Purdue University Indianapolis, told me back in 2015, "The main thing it does, I think, is establish the expectation in the public’s mind that access to basic health care is a right. It’s going to be hard to go back to a time when access to health insurance, and the subsidies to help pay for it, wasn’t near universal."

We’re about to find out how hard. On paper, it’s clearly possible for Trump and his allies in Congress to dismantle some or all of Obamacare. Some things Trump can unilaterally change by executive fiat — like redefining “preventive health care for women” to not include birth control. Other things he can do through the budget reconciliation process, like ending Obamacare's insurance subsidies, Medicaid expansion, taxes, and individual mandate. Budget reconciliation bills are filibuster-proof, so assuming more moderate-leaning Republican senators like Susan Collins don’t defect, Trump and the Republican Congress could pass all of that.

Still more things, like the extension of health insurance to 26-year-olds, can’t go through budget reconciliation and would face a Democratic filibuster — unless Senate Majority Leader Mitch McConnell ends the filibuster altogether, which is very possible given that it was ended for most nominations just three years ago.

The question is: Will they actually follow through, and if so, what will they replace Obamacare with? On the first point, it’s telling that McConnell has refused to commit to using budget reconciliation to repeal Obamacare. That opens the door to letting Democrats filibuster repeal efforts. Given the enormous political pain that could await Republicans should they suddenly deny 22 million people health care, it’s easy to imagine savvy operators like McConnell eyeing repeal warily, and looking for ways to act like they want to repeal the law while letting Democrats prevent them from actually doing so.

It’s also worth keeping in mind that while Trump has been consistently anti-Obamacare this election, he has in the past expressed very different views on government-subsidized health care programs, and it’s hard to know how firmly he’ll stick to his campaign pledges.

One possibility is that McConnell and Trump insist on including a replacement package in any repeal — and then the question becomes what precisely is in that package. Trump has promised to replace it with “something terrific” with “much better healthcare”:

I am going to repeal and replace ObamaCare. We will have MUCH less expensive and MUCH better healthcare. With Hillary, costs will triple! — Donald J. Trump (@realDonaldTrump) November 2, 2016

If that something is his stated replacement plan, which offers tax deductions for health insurance, the result will be a massive increase in the uninsured population. His stated approach effectively replaces the insurance subsidies and support of Obamacare with nothing at all.

But it doesn’t have to be that way. Avik Roy, a conservative health policy expert who has advised Rick Perry and Mitt Romney, has offered a right-leaning reform plan that repeals the Medicaid expansion, tax hikes, and individual mandate from Obamacare, but keeps insurance exchanges and preserves progressive, sliding-scale insurance subsidies for poor and middle-class Americans. Sens. Richard Burr (R-NC) and Orrin Hatch (R-UT), the latter of whom chairs the Senate Finance Committee, have offered a plan very similar to this. Paul Ryan's latest plan would preserve a refundable health care tax credit, albeit one that does not increase in size for poorer Americans.

These are not, to be very clear, Democratic proposals. They loosen insurance regulation on the exchanges considerably. Roy would abolish Medicaid for beneficiaries not needing long-term care, instead offering tax subsidies on the exchanges, while Burr and Hatch would block-grant Medicaid. These are not proposals that President Obama would have signed into law. But Roy asserts that his plan would increase health coverage by 9 million relative to Obamacare. Hatch and Burr would decrease it by 3 million, Ryan by 2 million.

I’m not sure I’m that optimistic about the plans’ effects. But even if they “only” reduce insurance by 5 million, that’s far, far better than outright repealing Obamacare and leaving 22 million people without insurance.

If the Roy plan, or the Hatch/Burr plan, becomes law, Obama’s health care legacy will survive in at least some form. Millions of people will continue to be insured who would not have been had he not pushed Obamacare through in 2010. But if Trump passes his current reform plan, then Obama’s greatest accomplishment, his pledge that the federal government will ensure near-universal coverage, will be destroyed.

The rest of Obama’s domestic legacy is likely to be wiped away

The thing about the welfare state is that it creates beneficiaries. If the new Republican majority chooses not to explode the uninsured population, it will be because they consider denying health care to 22 million people — and even more than that, should Medicaid be block-granted and gutted — to be a political catastrophe. At least some of those 22 million people vote, and they may be more inclined to turn out if their livelihood is under threat.

Not all elements of domestic policy are like this. Banking regulation, for instance, intensely affects the people who don’t like it — bankers — while having diffuse benefits across the citizenry. The number of Americans who voted against Donald Trump because they wanted to save Obamacare is significant. The number who voted against him to save Dodd-Frank is negligible.

And so it’s reasonable to expect that Dodd-Frank will be gutted. Trump has not offered many specifics on this, but Paul Ryan has indicated he would at the very least want to abolish the Consumer Financial Protection Bureau and the Financial Stability Oversight Council — the latter being a new oversight board created to ensure major financial institutions don't imperil the economy, and to force their breakup if they do.

You could do both of those through a combination of budget and executive policy — or through regular legislation. Trump could just not convene or use the FSOC. He and Congress could end its independent funding and subject it to a hostile appropriations process. And House Republicans also want to pass legislation subjecting all regulations to affirmative congressional rules, making it harder for future presidents to reverse Trump’s policies here. The budget-based path won’t face a filibuster. But even if some parts of this agenda are filibusterable, it’s not inconceivable that finance-friendly Democrats like Mark Warner could go along with some of it and get it to 60 votes.

Same goes for the environment. Obama’s climate policies are meant to benefit people far in the future, limiting the constituency that can fight rollback today. As Vox’s Brad Plumer explains, Trump can do an awful lot through executive action alone, by declining to defend Obama’s Clean Power Plan in court, or declining to enforce it, or ordering the Environmental Protection Agency to come up with new, weaker rules. This would all prompt a vociferous backlash from environmental groups in court, just as the Bush administration’s foot-dragging on global warming did, but it would change policy for years before the legal cases worked their way through.

The bigger question is whether Congress passes legislation stripping the EPA of the right to regulate greenhouse gas emissions under the Clean Air Act. This would face a Senate filibuster, but some Democrats, like Joe Manchin and Heidi Heitkamp, might support it, and McConnell might junk the filibuster altogether.

One place where Obama's legacy could last a bit longer is LGBTQ rights. Trump has shown no interest in reinstituting a ban on LGBTQ service in the military (a return of the ban on trans soldiers appears likelier), and the Supreme Court is loath to overturn recent precedents, which could help ensure that same-sex marriage remains the law of the land. But the fact remains that Obama's two Supreme Court appointments both replaced fellow liberals. He changed the courts in a serious way lower down, but the Supreme Court is split in roughly the same way it was before he took office, and Trump's replacement for Antonin Scalia will ensure it stays that way. Federal anti-discrimination policy will take a hit, but most of the Obama administration’s gains in this area are likely to be preserved.

Trump can undo much of Obama’s foreign policy

On foreign issues, Obama's record is perhaps the most successful of any Democratic president since Truman. He has reestablished productive diplomacy as the central task of a progressive foreign policy, and as a viable alternative approach to dealing with countries the GOP foreign policy establishment would rather bomb.

He rebuilt America’s reputation in the world and among its allies after the damage of the Bush years. Residents of countries like France and Germany came to trust us again. He showed his commitment to the NATO alliance by pushing back on Russian expansion in Eastern Europe. He made historic deals with Iran and Cuba that fundamentally altered America’s relationships with them. He tried extremely hard not to alienate Muslim communities abroad, including doing things that brought him tremendous flak like not using the term “radical Islam.” While not going far enough for some hawks’ taste, he forcefully condemned the Assad regime in Syria and armed rebels resisting it.

Trump promises to reverse almost all of this.

He has pledged to tear up the Iran deal and make a new one with Cuba. He is enthusiastically pro-Russia and sympathetic to Assad’s aims. He is widely loathed by residents of most other developed countries, and will augur a return to the Bush-era anti-American sentiment that pervaded European Union countries.

And he has promised to revive torture and vicious, uncompromising, civilian-indifferent warfare in the fight against Islamist terror groups. This will help radical Islamist groups’ recruiting and further damage America’s international reputation, undoing the progress Obama made by repudiating the Bush administration’s wars and torture regime.

There might be some things that remain. Maybe Trump blinks on Iran; he’ll be under tremendous pressure from EU countries to not renege on the deal. He’s signaled that he doesn’t want to cut off relations with Cuba entirely, which would preserve Obama’s historic opening there as part of his legacy.

But overall, we should expect a near-180 reversal from Obama to Trump here, and for much of Obama’s work to undo the legacy of the Bush administration to itself be undone.

Trump’s positive agenda is pure anti-Obamaism

And beyond all of that, Trump’s own policies — his Muslim ban, his border wall, his call for nationwide stop and frisk — represent a remarkable and large-scale repudiation of Obama’s vision for America, one that emphasized interreligious and interethnic tolerance, that sought to bring in Muslims at home and abroad as partners, that sought to protect millions of undocumented immigrants from deportation, and that used the Department of Justice to fight police departments that brutalized black communities.

Obama did not have a universally pro-immigrant record, marred as his first years were by historic deportation rates. But his second term featured a dedicated push for immigration reform, resulting in a Senate-passed bill and extensive executive actions that defended millions of undocumented immigrants from removal. Trump, by contrast, promises the most hostile administration immigrants will face since Calvin Coolidge.

Obama’s DOJ has taken police violence against unarmed black men extremely seriously, investigating and issuing incredibly damning reports in the aftermath of the shooting of Michael Brown in Ferguson and Freddie Gray in Baltimore. The DOJ has a significant amount of power in forcing reforms in local departments, and Obama was committed to using it. It’s hard to imagine Trump, the man who demanded the deaths of the Central Park Five and wants racially biased policing methods taken national, doing much of anything to crack down on these departments. It’s definitely hard to imagine Rudy Giuliani, who might become attorney general and who oversaw some fairly shocking police abuses as mayor of New York, caring much.

Obama began his presidency having to defend himself from racist attacks alleging he was a Muslim, and perhaps unsurprisingly he has continued George W. Bush’s strong rhetorical denunciations of Islamophobia. When 14-year-old Ahmed Mohamed was arrested for bringing a homemade clock to school, Obama invited him to the White House. He told a Gold Star mother who demanded he denounce radical Islam, “[w]hat I have been careful about when I describe these issues is to make sure that we do not lump these murderers into the billion Muslims that exist around the world, including in this country, who are peaceful, who are responsible, who, in this country, are fellow troops and police officers and fire fighters and teachers and neighbors and friends.”

He continued: “If you had an organization that was going around killing and blowing people up and said, 'We're on the vanguard of Christianity.' As a Christian, I'm not going to let them claim my religion and say, 'you're killing for Christ.' I would say, that's ridiculous.”

Trump, by contrast, wants to as a matter of national policy lump in the billion peaceful Muslims with radical terrorists, by enforcing a ban on Muslims entering the country. This is as clear a repudiation of Obama’s entire worldview, built on interracial and interethnic tolerance, as you can imagine in a successor.