Victorious Kentucky Democrat Jeff Taylor, surrounded by supporters

In a miraculous escape on Tuesday night, Kentucky Democrats hung on to their narrow majority in the state House, retaining two of their own seats and even picking up one from the GOP in a series of special elections. While every political portent pointed toward a loss for House Democrats, they remain the lone redoubt against complete GOP control of state government—and now they live to fight another day.

The story of how we even got here in the first place is a remarkable one, as Bluegrass Democrats had somehow managed to defy political gravity for decades. While Democrats in state after state were swept from power throughout the rest of the South, their counterparts in Kentucky managed to hang on, regularly winning the governorship and many statewide posts, and even holding the state House for a remarkable 95-year streak.

But last year's race for governor made it look as though that charmed existence had come to an end. In a poll-defying upset, tea partying businessman Matt Bevin, a weak candidate despised by the GOP establishment, crushed state Attorney General Jack Conway by nine points; most other Democrats seeking state office lost as well. By then, Democrats were clinging to just a 54-46 edge in the House, and with the legislature up for re-election this fall, it seemed like it would inevitably turn red soon, too.

And perhaps even sooner than November: Not long after Bevin's victory, two House Democrats switched parties and joined the GOP, while the new governor appointed two others to well-paid state jobs, prompting them to vacate their seats. Two Republicans, meanwhile, had won statewide alongside Bevin, and their seats became vacant as well, forcing a four-seat special election that would give Republicans an excellent chance of taking over the House—and with that, control over every branch of Kentucky's government.

It wasn’t just the longer-term trends that looked disturbing; the partisan leanings of those vacant seats were also a cause for deep Democratic pessimism. The bluest of them had gone for Mitt Romney by 9 points in 2012; the reddest by a whopping 38. What's more, Democrats everywhere usually fare worse in special elections, when there are no big-name races at the top of the ticket to juice turnout.