Democrats who opened the year clashing among themselves and lamenting President Trump's election have closed 2017 with victories that demonstrated their ability to weaponize party enthusiasm and draw a template for success in a sharply competitive battle for Congress in 2018.
For Republicans, Tuesday night's stunning loss by Roy Moore in Alabama's Senate race — the first GOP loss in a Senate race there in a generation — underscored a bleak passage of time: A year that began in unified control of Washington has ended with the party bitterly split and redefined in the worst of ways, saddled with an unpopular president and a Senate candidate accused of child molestation.
Certainly, Doug Jones' victory in Alabama was to some extent a fluke — an outcome made possible by Republicans' nominating a deeply flawed candidate, Moore, who many of the party's voters could not stomach. Turnout was tepid in key Republican areas, reflecting conservative voters who chose to sit this one out.
But that fluke was possible only because of problems within the GOP that will carry over into the new year, in which control of the House and Senate will be at stake.
The problems begin with Trump, for whom Moore's defeat represented a third straight repudiation.
The first came in September in Alabama, where Trump ambivalently backed incumbent Sen. Luther Strange, who lost to Moore in the Republican primary. Then Trump endorsed Republican Ed Gillespie in Virginia's gubernatorial race, only to have him lose by nearly double digits last month to Democrat Ralph Northam.
Finally, Trump transferred his Alabama endorsement to Moore and watched him lose in a state that has been ruby red for decades.
Even in Alabama, a state he won by 28 percentage points, Trump was unable to ease his candidate over the finish line. Exit polls Tuesday indicated one reason: Voters even in this heavily Republican state were closely split between approval and disapproval of Trump.
That's an ominous sign for Republicans heading into the midterm election. The key races next year will take place in states that are far less favorable to Trump than Alabama.
Related to Trump's broad unpopularity is the fact that his party is fractured. Those divisions began with the primary battle, which the president's former chief strategist, Stephen K. Bannon, who strongly backed Moore, helped turn into a referendum on the party's Senate leader, Sen. Mitch McConnell of Kentucky.
The splits only deepened after the Washington Post published accusations that Moore had fondled and kissed girls as young as 14 when he was a local prosecutor in his 30s.
The Republican National Committee and the party's Senate campaign committee pulled its backing from Moore after the Post story. When Trump, urged on by Bannon, decided to endorse Moore, the national committee returned to support him. The Senate committee declined to follow suit.
On election night, Moore's chief strategist, Dean Young, took off not against Jones or even the typical targets, Rep. Nancy Pelosi of San Francisco and Sen. Charles E. Schumer of New York, but against McConnell.
"I tell Sen. McConnell this: The people of Alabama are having an election tonight, and he should not overturn the people of Alabama," Young said, anticipating that a victory by Moore might be followed by a Senate Ethics Committee investigation.
On Tuesday night, it was clear that the bitter feelings among Republicans are likely to carry over to 2018 and beyond.
"The polls have been closed for 90 minutes & GOP could actually lose Senate seat. In ALABAMA," Alex Conant, a former spokesman for Republican Sen. Marco Rubio of Florida, tweeted Tuesday night. "No matter what happens next, hard to overstate what a huge political disaster this is for Moore-apologists like Trump, let alone Moore-champions like Bannon."
Moreover, in Alabama, and earlier in Virginia, Republicans found that arguments they have counted on to dispatch Democrats — that they are soft on crime, the military, immigration, guns and religion — no longer guarantee success.
Democrats have suffered from their own internal divisions, but in Virginia and Alabama, they benefited from an unrelenting tsunami of volunteers and money that have flowed from opposition to Trump. Indeed, outside groups have gotten more organized over time, a particular benefit in Alabama, where the party apparatus is weak.
As happened in Virginia last month, the Republican in Alabama fared more poorly than normal in suburban areas with large numbers of college-educated voters — a trend that could imperil a couple of dozen Republican House members next year. And black voters turned out in large numbers, a heartening sign for Democrats worried about motivating that central part of their party's base.
Those factors suggest a path for Democrats in the Republican-held House districts they will need to flip in order to take control next year, and perhaps even to contest the GOP's now-narrower hold on the Senate.
"Rounding the corner into a midterm year, I think the energy in Alabama underscores the importance of running competitive Democrats everywhere … with well-resourced campaigns," said Emma Brown, a campaign manager who ran a successful 2017 Virginia House of Delegates race by a first-time candidate against a seemingly strong Republican incumbent.
Brown is now managing a campaign by Democrat Lindsey Davis Stover against Republican Rep. Barbara Comstock in Washington's northern Virginia suburbs, expected to be one of the marquee House races in 2018.
Although Moore lost the race, Democrats are likely to continue to try to tie him around the necks of Republican candidates nationwide, a strategy they have been rehearsing over the last several weeks.
"Yesterday, my likely opponent, Josh Hawley, was asked point blank: If you were an Alabamian, would you vote for Roy Moore? He could have been clear and said no. Instead, he refused to take a stand, putting his party politics ahead of fundamental decency," Democratic Sen. Claire McCaskill said in a fundraising letter Tuesday.
"Whether you support a man like this is not a hard question to give a straight answer to…. Missourians deserve better than someone like that."
The territory is familiar for McCaskill: She won her Senate seat in 2012 by defeating Todd Akin, a Republican who created a huge backlash when he said that abortion rights were unnecessary for rape victims because in "legitimate" attacks, "the female body has ways to try to shut that whole thing down."
Trump, of course, won his election despite regular outbreaks of scandal, including accusations by more than a dozen women that he had made unwanted advances.
But the very different treatment of Moore, in a very Republican state, was yet another sign that the nation's political environment has changed.
Last year, it was Democrats who sat stunned on election night. Their party has yet to bind all of its wounds, and its divisions are sure to resurface ahead.
But Tuesday night delivered something necessary for a newly energized Democratic opposition: the path forward.