In perhaps the biggest Senate race upset in decades, Democrat Doug Jones defeated Republican Roy Moore on Tuesday to fill the Alabama seat once held by Attorney General Jeff Sessions. Moore, who was accused of sexual misconduct by nine women, lost by over 20,000 votes.

Just 13 months earlier, President Donald Trump won the traditionally right-leaning state by 588,708 votes and with 62 percent of the vote. Jones' success with flipping counties that supported Trump in the 2016 election, along with winning some Democrat-leaning counties by a higher margin, was crucial to securing a victory.

Jones defeated Moore in Alabama's most populated counties. Jones' strong showing in Jefferson County, which has a population of over 658,000, was perhaps his biggest accomplishment, defeating Moore, 149,522 to 66,309. In comparison, Clinton defeated Trump in Jefferson, but by a much slimmer margin: 156,873 to 134,768.

In Mobile County, Alabama's second most populous county, Jones defeated Moore by under 16,000 votes, while Clinton lost by roughly 23,000 votes.

Jones won Madison County, which is home to Huntsville and is the third most populated county, with 57 percent of the vote, compared to Clinton's 38 percent, receiving 26,000 more votes than Clinton. 

Clinton carried Montgomery County, 58,916 to Trump's 34,003, but Jones carried it over Moore by a much higher margin: 48,186 to 17,705.

One of Jones' most notable wins was in Tuscaloosa County, which is home to the University of Alabama, Shelton State Community College and the historically black liberal arts Stillman College. Trump defeated Clinton in the county, 47,723 to 31,762, while Jones earned a strong victory over Moore: 30,858 to 22,064.

Jones also closed the gap in some smaller counties that supported Trump. In Etowah County, which in total area is Alabama's smallest counties but also its most densely populated, Trump defeated Clinton, 32,353 to 10,442. But Moore carried it over Jones by just 15,693 to 10,518.

Young voters supported Jones with 60 percent of the vote, compared to Moore's 38 percent. Black voters overwhelmingly supported Jones over Moore, 96-4 percent. But a key vote was women, who supported Jones over Moore by a 57-41 percent margin.

“There was a movement, the resistance movement, the day Donald Trump was sworn in,” Ann Green, the chair of the Etowah County Democratic Party, told the Washington Post. “It didn’t just happen on the coasts. It happened in Alabama.”