The central idea pushing Democrats to pass the Affordable Care Act a decade ago was the desire to expand health-care access to more Americans. But Democratic elected officials also talked about a secondary benefit: creating a broadly used government program that would pay political dividends for the party.

That took a while to arrive. The legislation was not terribly popular when it passed, in part due to a general lack of awareness of what it entailed. When it first launched for public enrollment in October 2013, the glitchy website set a tone of ineptitude that helped flatten enthusiasm. During the course of President Barack Obama’s two terms in office, the legislation that was to be his political legacy and his party’s salvation had only lukewarm popularity and continued to be used as a cudgel by his political opponents.

Then came Donald Trump.

It’s not entirely true that opinions of the Affordable Care Act, better known as Obamacare, only turned around once the 2016 election passed. Views of the legislation did start to improve once people began enrolling in it — but only enough to reverse the plunge that followed the 2012 election (and that paralleled Obama’s own sagging popularity). It was simply this new part of government that people had to deal with and, despite Republican desk-pounding about repealing it, everyone understood it wasn’t going to go anywhere. Obama wasn’t going to sign a bill that unwound the effort, and it had already survived scrutiny by the Supreme Court in 2012. So it just lingered.

When Trump was elected, though, that changed. Suddenly this law that had, in fact, expanded health-care coverage both through subsidized coverage packages and by shifting enrollment boundaries for Medicaid was at risk of being rescinded. Between March 2016 and March 2017, overall favorable ratings for the legislation jumped eight points. On net (meaning the difference between favorable and unfavorable views), Americans went from minus-6 to plus-5 over that period, according to Kaiser Family Foundation polling.

Then Trump and the Republican majority in the House moved to actually dismantle the legislation. The effort was clunky, hindered by the fact that the party had nothing substantive with which to replace it — itself a reflection of the fact that there was never any need to develop an alternative during the Obama years. This became something of a joke in American politics, the idea that Trump and his party were always just about to release a new health-care proposal in a few weeks. But soon after Trump was inaugurated, a replacement plan emerged, passed the House and — died in the Republican-controlled Senate.

The short version of why that happened was that Sen. John McCain (R-Ariz.) opposed it, offering a dramatic thumbs down that became an eternal point of frustration for Trump. The long version is that the GOP was hoping to simply push through a consistently unpopular bill in the face of a surge in support for Obamacare, not only among Democrats but also independent voters that Republicans would need in midterm elections. It was hard to oppose Obamacare in that moment, just as Democrats had always hoped it eventually would be. Health care was a salient issue in 2018 and helped propel the Democrats to a majority in the House.

The effect of the GOP effort in 2017 was to demonstrate and, really, to consolidate the inertia that existed in support of the legislation. Perhaps a more popular GOP-backed bill may emerge and be passed, but it is no longer easy for Republicans to simply say Obamacare is bad and needs to be thrown out.

The party did slice away at the Affordable Care Act, stripping the unpopular individual mandate as part of the Tax Cuts and Jobs Act that Trump signed into law in December 2017. But that, too, may have aided the legislation, since the mandate that people have coverage was one of the less popular parts of the bill and the idea Obamacare would collapse without it has proved incorrect over the past three years.

On the campaign trail before his 2016 election, Trump made clear he would use all of the powers of the presidency to target the legislation.

“If I win the presidency,” he pledged in one 2015 tweet, “my judicial appointments will do the right thing unlike Bush’s appointee John Roberts on ObamaCare.”

This was an effort to channel conservative frustration at Chief Justice John G. Roberts Jr. for joining the liberal wing of the Supreme Court in 2012 to uphold the ACA as constitutional. But what was important was that Trump made the pledge: His nominees, if elected, would “do the right thing,” meaning they would undercut Obamacare.

His nominees just had that chance. But on Thursday, the justices rejected an attempt to dismantle the law on a 7-to-2 vote — with two of Trump’s three appointees joining the majority. Granted, the lawsuit that made its way to the bench was seen by experts as remarkably weak and the rejection was predicated on the court’s determination that those who were suing had no standing to do so. Nonetheless, Trump had promised that his justices would deliver a particular thing, and, given the opportunity, they didn’t.

In that way, too, Trump’s presidency helped Obamacare survive. The decision on Thursday was the third time the court has looked at the law and the third time that the law has emerged as viable. It was, in fact, the most overwhelming win the ACA has seen. It, too, helps cement the idea that the bill isn’t going anywhere, in part because it provides a disincentive to embark on yet another effort to disrupt the law through the courts.

For much of Obama’s second term, the Affordable Care Act was a Republican punching bag that Americans saw more unfavorably than favorably. There were looming legal fights and an unpopular mandate that people either have coverage or pay a tax penalty. Coming out of Trump’s presidency, the law is viewed with approval by most Americans, bolstered by legal victories and unburdened by the individual mandate.

In 2013 and 2014, Obamacare was mentioned in about 17,000 15-second blocks of coverage on Fox News. In 2017, as Republicans tried to repeal it, that jumped to nearly 24,000 blocks. But in the years since, it’s been mentioned only about 4,500 times in total. The attention of conservative media has moved on.

Trump pledged to use his presidency to junk Obamacare. Instead, his presidency saved it.