Timothy D. Easley / AP

Conservative businessman Matt Bevin won the Kentucky gubernatorial race on Tuesday night, handing the Republican Party its 31st governorship in a state that has elected Democrats to that office all but once since the presidency of Lyndon B. Johnson.

Bevin’s victory comes as a surprise after pre-election polls showed Kentucky Attorney General Jack Conway, the Democratic candidate, holding a slight to substantial lead. Instead, Bevin won the race by a margin of 52 to 44 percent, with 99 percent of precincts reporting. Bevin also ran a sometimes-troubled campaign marked by friction with the state and national GOP establishment, as my colleague Russell Berman reported last month.

Things were looking rosy for Republicans in Kentucky. And then came Matt Bevin. Again. The Tea Party outsider had tried to oust McConnell in a primary challenge, and had been routed. But a year later, he squeaked out a victory (by 83 votes!) in the GOP gubernatorial primary over the party’s preferred candidate, James Comer. Republicans—McConnell included—reluctantly embraced their unlikely standard-bearer, but Bevin’s path to the governor’s office has not been smooth.

Conway has vastly outspent Bevin on television, and the Democrat has maintained a small but sturdy lead in the polls. Republicans have been frustrated both by Bevin’s frequent missteps and by the manufacturing executive’s hesitance to put much of his own money into his campaign. Late last month, the Republican Governors Association pulled its TV ads for Bevin, sending a signal it believed the race was lost. Bevin responded by putting up a million dollars worth of commercials on his own, and on Tuesday morning, the RGA announced it was going back on the air for the last two weeks of the race. “We decided to go back in because we’ve been doing the polling, and the polling shows the race very winnable,” RGA spokesman Jon Thompson told me.

Bevin fought back hard by emphasizing his outsider credentials—an easy argument to make after his high-profile scuffles within his own party—and praising Donald Trump, whose anti-establishment campaign upended the GOP presidential contest. He also rallied to the defense of Kim Davis, the Rowan County, Kentucky, clerk who was briefly jailed this summer for defying a federal court order to enforce the U.S. Supreme Court ruling that legalized same-sex marriage nationwide.

Some Democrats, surprised by Bevin’s come-from-behind win, blamed the fierce anti-establishment mood that suffuses the current political landscape for their defeat. “Attorney General Jack Conway ran a strong campaign focused on the issues that matter to Kentuckians: good schools, good-paying jobs, and economic opportunity,” said Elisabeth Pearson, the executive director Democratic Governors Association, in a statement after the loss. “Unfortunately, he ran into the unexpected headwinds of Trump-mania, losing to an outsider candidate in the Year of the Outsider.”

Bevin will succeed incumbent Steve Beshear, a Democrat who could not run for a third time due to term limits. Despite Beshear’s popularity among Kentuckians, Bevin campaigned against his record and his signature achievement: the creation of KYnect, one of the state health-insurance exchanges formed under the auspices of the Affordable Care Act. The Washington Post’s Dave Weigel referred to Kentuckians’ divergent views of Obamacare and KYnect as “one of the great paradoxes of American politics.”

In polls, Kentucky voters rejected Obamacare at roughly the rate they rejected the president, 2-1. But they were fond of KYnect, which Beshear created by executive order, bypassing a gridlocked Kentucky legislature. Month by month, Kentuckians took advantage of the state's Medicaid expansion or the plans offered on the exchange, and the state's uninsured rate plummeted from 20.4 percent to 9 percent. Beshear predicted that "the Democratic nominee will make this a major issue and will pound the Republicans into the dust with it.”

But the opposite happened. Bevin campaigned on shutting down KYnect and transferring those on it to the federal exchange, as well as reversing the state’s expansion of Medicaid under the Affordable Care Act. The impact on health care in the Bluegrass State would be significant if both programs are reversed. About 400,000 Kentuckians qualified under the ACA’s Medicaid expansion, according to the Huffington Post, and another 100,000 received health insurance through KYnect.

While some states have refused to implement the Act’s Medicaid expansion in the first place, Kentucky would be the first state to reverse the expansion after its acceptance. Bevin’s success (or failure) could herald the next wave of political battles to be fought over the implementation of President Obama’s signature domestic legislative achievement.

We want to hear what you think about this article. Submit a letter to the editor or write to letters@theatlantic.com.