As the sun was coming up this morning, the outcome of the Kentucky governor’s race was still up in the air, but it wasn’t looking good for Republican incumbent Matt Bevin. NBC News was already giving the race to his opponent, Democrat Andy Beshear, while the AP was saying it was still too close to call. But with nearly all the precincts reporting, Bevin appeared to be roughly ten thousand votes behind. Beshear declared victory, but Bevin had yet to concede.

Kentucky Attorney General Andy Beshear pulled off an upset Tuesday night in an apparent victory over Republican Gov. Matt Bevin, dealing a blow to President Donald Trump, NBC News projects…

In Kentucky, Trump couldn’t save the unpopular Bevin after campaigning with him the night before the election in Lexington, where the president told supporters a loss by the GOP governor would be portrayed as Trump’s having suffered “the greatest defeat in the history of the world.”

With 99 percent of precincts reporting, the candidates were separated by less than 10,000 votes. Beshear was leading with 49.4 percent, or 706,865 votes, to Bevin’s 48.7 percent, or 696,918 votes.

When I turned on CNN this morning, the crew there was already doing their best to make Trump’s prediction come true and paint this as a defeat for the President, and since he had personally gone down to the Bluegrass State to try to drag Bevin over the finish line I suppose that’s technically true. But some fairly recent polls showed Bevin trailing Beshear by more than a dozen points. Assuming he loses, it will be by roughly one or two points, so it appears that Trump did indeed rally the vote for him and deliver a better than anticipated turnout.

Still, it’s tough to say how much of this you can really pin on the President. As of last month, Morning Consult still had Trump’s approval rating in Kentucky at plus 15. Also, Kentucky voters have continued to hand control of both houses in the legislature to the GOP for the past three years on top of previously electing Bevin, so they clearly don’t have an issue with voting for Republicans.

The fact is that Bevin just wasn’t a popular governor in his home state. The press is jumping all over themselves today to remind everyone that Bevin was ranked as the second least popular governor in the country. (Behind only the scandal-plagued Democrat Gina Raimondo in Rhode Island.)

Bevin didn’t do himself any favors with some of the political battles he picked to fight while in office. We’re talking about a state where a Republican should easily be able to stay afloat, but Matt Bevin seemed to find a way to get under people’s skin. With all that in mind, it’s probably a miracle that he came this close to reelection and one could credibly argue that he only pulled within ten thousand votes because Trump showed up to throw him a lifeline.

Either way, we may have to wait for a recount if Bevin decides to request one. (He can, but he’ll have to pay for it out of his own campaign funds if he does.) But finding ten thousand votes won’t be any small feat. At least for the moment, it looks like the Democrats have rung up one of several victories in that red state.