ANALYSIS: Ed Gillespie made a bet.
By embracing the political priorities of US President Donald Trump, he figured, he could help bolster enthusiasm from Trump-supporting voters who'd nearly blocked his nomination to be the Republican nominee for governor in the American state of Virginia.
Those voters had apparently preferred Corey Stewart, a candidate who'd internalised Trump's politics in a way that Gillespie hadn't.
So, as Election Day approached, Gillespie ran a number of ads highlighting immigration, sanctuary cities and gang violence, despite the fact that crime is much lower in Virginia than in most of the rest of the US.
* US voters deliver first rebuke to Trump
* What does Democrats' win say about 2018 midterm vote chances?
* Stunning win after on-air tragedy
* Trump keeps vanquished foe in sights
* Trump warns North Korea: 'Do not try us'
It was a gamble, but polling suggested it might be working. His opponent, Ralph Northam, saw his lead over Gillespie erode over the past few weeks.
Trump himself weighed in for Gillespie in a series of tweets and with automated Election Day phone calls encouraging turnout.
On Tuesday night, the bottom fell out.
Largely on the strength of an unexpected surge in turnout, Northam won easily.
Expected to prevail by a bit over 3 points, he'll end up with a victory of at least twice that size.
After a close loss in a Senate race in 2014, Gillespie lost again, this time by much more.
Trump wasted no time in distancing himself from Gillespie, enjoying the spaciousness of his now-280-character tweets: "Ed Gillespie worked hard but did not embrace me or what I stand for. Don't forget, Republicans won 4 out of 4 House seats, and with the economy doing record numbers, we will continue to win, even bigger than before!"
This was not a wise tweet.
We've noted before that Trump has an insurance premium against any calls for his impeachment.
His popularity with Republicans has slipped since the beginning of his presidency, but he's still very popular with them, particularly more conservative members of his party. (Per Gallup, more than 9-in-10 conservative Republicans approve of Trump.)
Since Republican Party primaries see an over-representation of conservatives, that meant that Republicans eager to win re-election to Congress were less likely to turn on the president.
What happened after those primaries, though, was anyone's guess. Tuesday night offered some sense of what that might be.
Trump's tweet distancing himself from Gillespie sugarcoats the election in a way that might make Trump feel better but probably isn't fooling anyone on Capitol Hill.
His claim that Republicans won four out of four federal races misses a few important points.
The first is that those races were in Republican-held districts. The second is that the Democrats saw big gains in most of those races relative to past elections. The third is that the figure is actually 4-of-5; Trump likes to ignore a race in California won by the Democrats.
But it also does something very dangerous for Trump right now. It shows, yet again, that he isn't loyal to his political partners.
We've seen this before.
When Trump backed the House effort to repeal-and-replace Obamacare (having no plan of his own), he responded to its passage by declaring the bill to be "mean" - as though he hadn't previously claimed it was nearly without flaw. (It was health care, not immigration, that was the big issue in Virginia, according to exit polls. Northam won among voters concerned about health care by a more than 3-to-1 margin).
Even before Election Day in Alabama earlier this year, Trump began to distance himself from his preferred candidate Republican Senate primary, Luther Strange, hinting that he'd perhaps made a mistake - a shift that was certainly informed by polls showing a likely Strange loss.
When that happened, Trump deleted some of his tweets of endorsement.
Strange's campaign, unlike Gillespie's, didn't embrace Trumpist politics like the threat of the gang MS-13.
He tried to win as a more typical establishment conservative, to no avail.
Gillespie tried to more directly embrace Trump politics - and lost badly. And then saw Trump turn on him.
Think of the message that Trump's sent to Republicans.
Stand with him on policy and have him bad-mouth what you passed.
Embrace his endorsement and see a loss followed by Trump downplaying the endorsement.
Embrace his endorsement and his politics, and see a loss and words of criticism.
These are all one-offs - but politics generally suffers from a small sample size from which to draw conclusions, and no one spends more time trying to draw conclusions than politicians themselves.
What's the upside? There is no race in which one can say Trump helped the Republican win.
In Georgia's 6th District, for example, the Republican prevailed - but by about the same margin that the Republican candidates had enjoyed in the primary.
It's not only Trump that was proven to be disloyal on Tuesday night.
Stephen Bannon said this week: "[I]t was the Trump-Stewart talking points that got Gillespie close and even maybe to victory. It was embracing Trump's agenda as personified by Corey's platform. This was not a competitive race four weeks ago. You could have stuck a fork in Gillespie."
Four weeks ago, Gillespie trailed by about 6 points in the RealClearPolitics average.
He lost by more than that. And after he lost, Bannon's Breitbart, the site he manages, declared in a main headline that Gillespie was a "Republican swamp thing" who, it was implied, deserved to lose.
Bannon's running track record in electoral politics? He helped Trump lose the popular vote and win the electoral college in 2016.
He embraced Luther Strange's opponent after Strange was already trailing. And now he watched the "Trump-Stewart talking points" lead nowhere.
On its home page, Breitbart also championed Trump's argument that Gillespie should have embraced him more robustly.
That's a flawed theory.
Trump is very unpopular in Virginia, and Northam won among those who disapprove of Trump by a 7-to-1 margin, according to preliminary exit polls.
A third of voters said their vote in the race was meant to send a message of opposition to Trump - twice as many as said it was a message of support.
What's more, Trump made his feelings clear. Those who wanted to vote for Trump's candidate knew who that candidate was.
As in Alabama, voters went another direction.
It's critical to remember that Democrats were supposed to win this race, albeit not necessarily by as wide a margin as they did.
Democrats hold the governor's mansion and Hillary Clinton won by 5 points last year.
Trump could have congratulated Gillespie on a hard-fought race and noted the uphill battle. Instead, he decided to try to spin the loss to his advantage.
It's unlikely that many Republicans worried about next November will be convinced by Trump's argument.
Instead, they're likely to take another lesson: Trump can't deliver a victory for you when you're trailing, and neither can Trumpism. (In fact, there's every reason to think that Trump was the liability that his poll numbers would suggest, with Gillespie doing fine in western Virginia but getting beaten badly in the more-Democratic northern District of Columbia suburbs.)
Nor will Trump stand with you should things go south.
If, next summer, the question of Trump's fate as president is raised, how might Republicans in centre-right districts be expected to evaluate that decision?
- The Washington Post