From unpredictable special elections and primaries to a historic midterm election, 2018 will be remembered as a year of significant political upheaval, both in Washington and across the United States.

Driven by opposition to President Donald Trump and a desire for a more representative group of members of Congress, the Democratic Party transformed its membership, while Republicans largely doubled down on the Trump agenda as they solidified their base and increased their standing in red states.

Here's a look back at five of the biggest moments that shaped the year in politics:

Lamb's special election upset helps expand the Democratic map

Though Election Day nationwide was still eight months away, it can be argued that the Democratic wave began in March when federal prosecutor Conor Lamb staged the upset of the year in Pennsylvania's 18th Congressional District -- a district that voted for President Trump by a 20-point margin over Hillary Clinton in the 2016 presidential election.

Lamb defeated Republican State Sen. Rick Saccone by fewer than 700 votes but parlayed the momentum from the victory into another win in November when he beat fellow Rep. Keith Rothfus by a far more comfortable 40,000 vote margin in the state's newly redrawn 17th congressional district.

For Democrats, Lamb's special election victory re-calibrated expectations, growing their electoral map and convincing the party it was worthwhile to invest in parts of the country in which the party had not recently been competitive.

The decisions paid off in November when Democrats won House seats in red states like Georgia, Oklahoma and South Carolina and waged closer-than-expected Senate battles in Tennessee and Texas.

Looking ahead, the inroads made in these regions could tilt the presidential map in 2020.

Ocasio-Cortez's primary defeat of Crowley elevates progressives

Ten-term New York Rep. Joe Crowley hadn't faced a primary challenge in 14 years when then-28-year-old Alexandria Ocasio-Cortez toppled him in the 14th Congressional District Democratic primary in June, a major victory for the liberal wing of the party and the first sign of a looming generational shift in Washington.

Crowley, the House Democratic Caucus chair, was seen as a potential future Speaker of the House with significant clout in the Capitol, but that didn't stop Ocasio-Cortez, who worked for Bernie Sanders' presidential campaign and had been bartending less than a year earlier, from rallying voters in the Bronx and Queens on her way to a 15-point margin of victory.

Ocasio-Cortez's victory was followed by Boston City Councilor Ayanna Pressley's defeat of Rep. Mike Capuano in Massachusetts as Democrats increasingly sought out more diverse candidates within their ranks, and potentially ushered in an era of comfort among Democrats with far-left Democratic-Socialists. Both Ocasio-Cortez and Rashida Tlaib of Michigan, another Democratic-Socialist, would win election to the House in November, while DSA membership nationwide swelled to nearly 50,000 people.

New generation of rising stars emerges

In addition to Ocasio-Cortez and Pressley, 2018 featured a number of candidates who captured nationwide attention and appear poised to play a role in the future of their parties.

On the Democratic side, three candidates who went on to lose their 2018 election are already rumored to be eyeing their next races. Texas Rep. Beto O'Rourke, who fell in his challenge of Sen. Ted Cruz, is considered a top contender should he run in the Democratic presidential primary. He may be joined in that race by Tallahassee, Florida, Mayor Andrew Gillum, who was unsuccessful in his gubernatorial election, but recently met with former President Barack Obama. And Stacey Abrams, the Democrats' nominee in Georgia's gubernatorial election, is already leading efforts in the Peach State to combat voter suppression, and many of her supporters have been encouraging her to challenge Sen. David Perdue, who is up for reelection in 2020.

Republican Missouri attorney general Josh Hawley will become the youngest member of the Senate in January after he defeated Sen. Claire McCaskill in November, and will be joined in that chamber by Rep. Martha McSally, a former Air Force fighter pilot who lost her race to fellow Arizona Rep. Kyrsten Sinema, but was appointed to succeed Sen. Jon Kyl in serving the remainder of the late Sen. John McCain's term.

Brett Kavanaugh hearings divide lawmakers, campaigns

The accusations of sexual assault against Judge Brett Kavanaugh not only divided the country during his confirmation hearings, but may have had a significant impact on the makeup of the Senate and future political campaigns.

Democratic Sens. Heidi Heitkamp, Joe Donnelly and Claire McCaskill each faced difficult reelection campaigns in North Dakota, Indiana and Missouri, respectively, but their highly publicized votes in opposition of Kavanaugh's confirmation may have been the final straw for moderate and Republican voters in their red states who had previously crossed party lines for them.

Meanwhile, several Democratic members of the Judiciary Committee who questioned Kavanaugh seemed to use the opportunity to build name recognition ahead of potential presidential campaigns. Sens. Cory Booker, Kamala Harris and Amy Klobuchar each engaged in spirited back-and-forths with the judge, earning mixed reviews that could play into the 2020 conversation.

Diverse Democratic wave takes back House

Though Republicans were quick to tout their gains in the Senate, the major story on Election Night and in the weeks that followed was the 40 seats picked up by Democrats and the diverse composition of the newly elected House class.

More than 100 women won elections to the House in November, the largest number in history, along with 100 non-white members of Congress. Several more winners achieved historic firsts: Deb Haaland of New Mexico and Sharice Davids of Kansas became the first Native American women to be elected to the House, while Ilhan Omar of Minnesota and Tlaib became the first Muslim congresswomen.

Democrats ended the year with a 36-seat advantage over Republicans -- one which could still grow, depending on developments in the contested North Carolina 9th district election -- and Nancy Pelosi poised to again be elected as Speaker of the House.

Allegiance to Trump tested at the polls

In the aftermath of the election, unsuccessful House Republicans were quizzed on whether Trump helped or hurt his party, particularly in the most competitive races.

Trump's endorsement record in House races was an above-average 24-16, but was also boosted by his weighing in on some relatively safe races. Results pointed to no one true formula for success. In New Jersey, Trump-phobic Rep. Leonard Lance was defeated as he sought his sixth term, but so was Rep. Tom MacArthur, who embraced the president and his major tax reform and Obamacare repeal efforts, exemplifying the dilemma many Republicans found themselves in.

But the president's opinion on the matter was crystal clear, arguing that his "vigorous campaigning stopped the blue wave,” and that some GOP losers, like Rep. Mia Love, owed their defeats to their distance from his administration.