The Maryland General Assembly at the Maryland Statehouse in Annapolis on Jan. 10. (Jonathan Newton/The Washington Post)

COURTS HAVE historically shied away from striking down redistricting plans for fear of showing favor to one party in a process that is inherently political. But recent decisions by state and federal judges in North Carolina and Pennsylvania suggest that the judicial branch thinks partisan gerrymandering has gone too far and needs to stop. We hope lawmakers in Maryland and Virginia are paying attention and that those decisions serve as a trigger for them to overhaul how their states' legislative and congressional districts are drawn.

Both states — and both parties — are guilty of egregious abuses of gerrymandering, as evidenced by the particulars of pending court cases. In Maryland, it was Democrats, in control of the legislature and governor's office, that redrew congressional districts in 2011 to unseat Republican Roscoe Bartlett by including more Democrats in his Western Maryland district. In Virginia, it was the Republican-led General Assembly that drew a 2011 statehouse map that packed minorities into a small number of districts to increase the GOP advantage in surrounding areas. The Supreme Court is set to hear a challenge to Maryland's map, Benisek v. Lamone, and last year it ordered a lower court to reexamine the Virginia case, Bethune-Hill v. Virginia State Board of Elections. A decision could come any day.

But it shouldn't take a court order to get lawmakers to do the right thing. Redistricting historically has allowed the party in charge to draw lines in a way to give it a certain edge. But there should be limits and, more importantly, a sense of fairness that does not distort the political landscape at the expense of certain voters. "Invidious partisan intent" was the phrase used by a federal three-judge panel in North Carolina in declaring Republican-drawn congressional district lines unconstitutional. More than one party has been damaged — the polarization of today's politics can be traced in part to the creation of safe seats in which incumbents only worry about primary challengers and see no gain in compromise with the other political party.

Maryland Gov. Larry Hogan (R) and Virginia Gov. Ralph Northam (D) support redistricting reform, but they are faced with legislatures controlled by the opposing party that have a vested interest in a status quo that protects incumbents. Mr. Hogan's decision to sign a friend-of-the-court brief in support of the plaintiffs in Benisek v. Lamone and his continued push for an independent redistricting commission focus needed attention on this critical matter in an election year. We hope that will build public support for change, making it harder for Democrats to stay on the wrong side of the issue.

In Virginia, redistricting-reform advocates are trying to build momentum for next year, when they hope to start the process for a constitutional amendment needed to create an independent commission. In the meantime, several bills have been introduced in the current session that would lay the groundwork for change, including a measure to hold public hearings to consider an independent commission. The outcome of those bills will answer the question of whether the closeness of last year's elections has changed Republican minds about the value of nonpartisan redistricting or made Democrats less reform-minded.