Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

WASHINGTON — When Martin O’Malley was governor of Maryland, he worked hard to draw congressional districts that would favor Democrats and squeeze out Republicans. Now, he wants the Supreme Court to scrap his map and crack down on partisan gerrymandering.

The justices this week heard a lawsuit filed by Maryland Republicans that alleges they were disenfranchised when Democrats, under O'Malley, re-drew congressional districts after the 2010 election in a way that made it virtually impossible for a long-serving House Republican to win re-election.

The court is also considering a similar case brought by Democrats in Wisconsin, where Republicans drew a map that favored them.

Reformers are hoping that by taking up both cases, each targeting a different party, the Supreme Court is preparing to, for the first time, set real restrictions on partisan gerrymandering.

For O’Malley, who ran for president in 2016, that would be well worth losing the map he helped draw and the one extra congressional seat Democrats gained from it.

"Our country and our democracy is not served well by partisan redistricting," O’Malley said in a recent interview. "And if this is one of the ways we make progress for our republic, we're glad to be a part of it."

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

O’Malley was deposed by the plaintiffs in the Maryland case, who were stunned when he immediately copped to drawing the maps with partisan intent and told them he was rooting for their cause.

"I said, 'Good luck, I hope you're successful,'" O’Malley said of his deposition. "They scheduled me for four hours and I think we were done in, including the break, like 40 minutes."

Currently, racial gerrymandering is prohibited, but it's perfectly legal to draw legislative districts in a way that favors one party and punishes another.

That helps explain how states like Pennsylvania and North Carolina, which vote roughly 50-50 in presidential elections, end up with lopsided congressional delegations where Republicans outnumber Democrats almost 3 to 1.

Today, gerrymandering is virtually synonymous with Republican gerrymandering, but that’s mainly because the 2010 Tea Party wave election put the GOP in power just as states were engaging in their decennial redistricting process.

Democrats gerrymander, too, as Maryland shows, just not nearly to the extent Republicans have.

"I did everything in my power to draw a map that would be more favorable to the election of a Democratic congressional delegation," O'Malley said. "In 2010, many of us in Maryland felt an obligation to push back against rank, extreme, Republican gerrymandering that was going on in many states across the United states."

He compared it to the way Democrats use super PACs, even though the party ultimately wants to do away with them.

Of course, it’s relatively easy for O’Malley to speak out now, since he’s out office and doesn’t have to worry about protecting incumbents in the state capital.

In Annapolis, meanwhile, Democrats have defended their map and blocked attempts by Maryland’s current governor, Republican Larry Hogan, to advance the kinds of redistricting reforms that Democrats champion in other (often Republican-controlled) states.

"For three years, my administration has proposed reforms to create a nonpartisan system for drawing district lines. But legislators are content with the broken status quo, in which elected officials pick their constituents. Voters deserve better," Hogan wrote in a recent op-ed in The Washington Post.

When the president of the Maryland Senate, a Democrat, gave his own deposition in the case, he plead ignorance.

"Did partisan factors play a role in the Maryland Senate consideration of the 2011 congressional map?" the lawyers asked.

The state Senate leader replied, "I don’t believe so."