Democrats eyeing the 2018 midterm elections have a lot to feel optimistic about—fired-up liberal activists are thronging to protests and town halls, low-dollar donors are opening their wallets, candidate recruitment is setting records.

But Democrats also face a massive handicap: cleverly drawn electoral maps that dramatically favor Republicans, in both House and state legislative races. Democrats have mounted an aggressive, multi-million dollar effort to fight back against district lines that they say were unfairly and even illegally drawn. And they may get an assist from the Supreme Court.

The practice of gerrymandering—manipulating electoral boundaries to favor the party in power—is hardly new, and the arcane topic of redistricting typically makes voters’ eyes glaze over. But the issue is drawing national attention amid mounting voter anger, a string of state and federal lawsuits, and growing concern among Democrats that gerrymandering could lock them out of power for another decade.

“It is unfair, it is undemocratic and in many of these states it is illegal,” says Kelly Ward, executive director of the National Democratic Redistricting Committee, a new super PAC that is raising big money from Democratic donors and has a projected budget in the millions for the 2018 election cycle.

Unveiled in January by Eric Holder, President Obama’s former attorney general, the PAC will use legal, political and high technology tools to help tilt the playing field back toward Democrats. To that end, the PAC will help Democrats in their efforts to win gubernatorial and state legislative seats so that the party has a say in drawing district lines in 2021, following the 2020 Census.

Organizers are also eyeing ballot initiatives in such states as Michigan, Missouri, and Ohio that would require better bipartisan representation in the drawing of electoral maps. Their biggest champion is Obama himself, who has flagged redistricting changes as a leading priority, and called for district lines that “encourage politicians to cater to common sense and not to rigid extremes” in his farewell address.

In one sense, Democrats are emulating what Republicans did in 2010, when the GOP poured millions into a campaign to capture governors’ mansions and state legislatures with the express purpose of controlling the 2011 redistricting that followed the last Census. The strategy was wildly successful, deploying sophisticated software to draw GOP-friendly districts that were so watertight that they virtually wiped out all Democratic competition.

A report released last month by the Brennan Center for Justice found that partisan bias in the GOP-drawn maps gives Republicans a net benefit of 16-17 congressional seats—a good chunk of the 24 seats Democrats would need to regain control of the House in 2018. The most extreme levels of bias are concentrated in just seven states, the report found, all but one of them swing states.

“In the states that have the worst gerrymanders, the maps not only provide a Republican advantage, but it seems to be a pretty durable Republican advantage,” says Michael Li, the Brennan Center’s senior redistricting counsel and one of the report’s authors. Li notes that some of most elaborately drawn districts cropped up in states, such as North Carolina and Texas, with rapidly growing minority populations.

But GOP gerrymandering arguably succeeded too well—hurting Democrats but also creating ultra-safe GOP seats where the only danger to some Republican incumbents comes not from a general election but from a more-conservative primary challenger. That’s empowered far-right lawmakers, aggravating the intra-GOP struggles that now may derail the Republican agenda.

It’s also fueled voter anger at an increasingly polarized, gridlocked and unresponsive Congress, and spawned multiple lawsuits. Alabama, Georgia, North Carolina, and Texas are among the states facing suits that allege illegal racial gerrymandering in GOP-drawn state and-or congressional districts. Last week the Supreme Court upheld a lower court finding that North Carolina violated the Constitution’s Equal Protection clause when it drew the boundaries of two congressional districts with race as the primary concern.

The ruling has sparked speculation that the high court might be poised to look at partisan gerrymandering in a more critical light. The court has long held that gerrymandering for political (and not just racial) reasons raises constitutional concerns, but has lacked a bright-line test to define it.

In a case known as Gill v. Whitford that is now wending its way to the Supreme Court, a federal panel found that Wisconsin’s state house maps were unconstitutionally partisan. The case is seen as a key test of the Supreme Court’s willingness to curb ultra-partisan electoral maps.

Republicans have mounted their own challenge, arguing that the boundaries of Maryland’s sixth congressional district, drawn by the Democratic-controlled legislature, are unconstitutionally partisan. Should Democrats make headway in their redistricting campaign, they may need to fight the temptation to simply turn around and protect their party’s incumbents, as Republicans did in 2010. The high road for Democrats would be to support legislation authored by California’s Zoe Lofgren, in the House, that would require all states to follow in the footsteps of Arizona and California, and place redistricting in the hands of an independent, nonpartisan commission.

“We don’t want to gerrymander on behalf of Democrats,” insists Ward, of the National Democratic Redistricting Committee. “We want to have Democrats at the table so that we can make sure that the process is more fair.”

But Ward acknowledges that Democrats’ redistricting campaign is also about political survival. The way House districts are drawn today makes it “very, very hard” for Democrats to win, says Ward. “They are locked against Democrats.”